KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am writing a shell script to batch process .mov files off my camera through Handbrake to save HD space. The script searches a directory with 'find' and then runs Handbrake on each .mov file found, matching the creation date of the resulting file to the source file's date with 'touch'. I originally did this with a for loop: for i in $(find "$*" -iname '*.mov') ; do ~/Unix/HandbrakeCLI --input "$i" --output "$i".mp4 --preset="Normal" touch -r "$i" "$i".mp4 done This worked, but failed if the input files had spaces in their file names. So I tried a while loop instead: find "$*" -iname '*.mov' | while read i ; do ~/Unix/HandbrakeCLI --input "$i" --output "$i".mp4 --preset="Normal" touch -r "$i" "$i".mp4 done The problem with this loop is that it works for the first file in the directory, and then exits the loop. Note that if I substitute an "echo $i" in the body of the while loop, it prints all of the .mov files in the directory, so the loop is structured correctly. I believe there is a partial answer to my question on this stackoverflow thread . But the solution is specific to ssh and doesn't solve the general problem. Seems to have something do do with stdin being used by a sub-process, but I don't exactly understand how this works. Any advice? I'm on OSX 10.6
Tags (comma-separated)
Save Edits
Cancel