الاثنين، 19 شوال، 1434 هـ

Rewrap Multiple AVCHD Files Using RewrapAVCHD in One Shot

I was looking for a tool to convert the AVCHD (.mts) video files generated by my Sony HD Handycam to a usable format in my iMAC. RewrapAVCHD is one great solution. You can use the tool to select your file and then convert it very quickly to iMovie and quicktime friendly format. However, it suffers from a major problem, which is the lack of batch processing mechanism. To convert multiple files, you have to open them one by one and wait for each one to finish. For people with dozens of files like me, this is not a viable solution. To work around this problem, I automated this lengthy process using Bash scripting.

First I tried to write a simple for loop to go through all the files in the directory and convert them. This didn't work since the tool doesn't terminate after the end of conversion. Therefor, I had to write two separate for loops. The first loop monitors the directory for the creation of the output file then kills the app. The second loop goes through the files one by one and open them using the tool. Below are the two scripts:

First loop:

# for i in `ls ~/Movies/My_files/|grep MTS|tr "." " " |awk '{print $1}'`; do j="1"; while [ $j -eq 1 ]; do sleep 2;ls ~/Movies/My_files/$i.m4v; j="$?"; done; killall RewrapAVCHD; done;


Second loop:

# for i in `ls Movies/v_old2|grep MTS`; do ~/Desktop/RewrapAVCHD\ 1.0b4/RewrapAVCHD.app/Contents/MacOS/RewrapAVCHD Movies/v_old2/$i; done

To run the loops, simply open two terminals and copy and paste each loop on a different terminal with modifying the location of the directories to where you keep the tool and your files.