how to find and move a file recursively?
I'm trying to search through a media directory which has a number of sub-directories for any files with a specified string "baby" in them which all end in .mp4 extension. I would then like to either move those files to a specific directory or run handbrake from the commandline to convert them to *.avi (preferrably the latter).
Can anyone help me with a bash command line argument that will do this? I'm thinking of using the find command and then piping the result into exec running handbrake on the found filename, but I'm not sure of the syntax. |
part of the way there
find . -name "*.mp4" -exec grep baby {} \; |
Something like this?
Code:
find . -iname "*baby*.mp4" -exec handbrake {} \; |
Quote:
Code:
find . -name "*baby*.mp4" -exec handbrake HANDBRAKEOPTIONSHERE \; |
Thank you for the help. Question: I have figured out the Handbrake commands and I have figured out the above commands that you suggested. There is only one issue.
Input name: baby-christmas-2011.mp4 Output name: baby-christmas-2011.mkv How can I just change the .mp4 to mkv when the {} returns "baby-christmas-2011.mp4"? Is it possible to manipulate it while using {}? |
There might be a way to do that within -exec, but if it were me I would probably just modify the command a bit for that:
Code:
find . -name "*baby*.mp4" | while read file; do Code:
find . -name "*baby*.mp4" | while read file; do handbrake -i "$file" -o "${file/.mp4/.mkv}"; done |
Thank you for that. How does $file get a value?
while read file Is this where it is loading the file name into $file? |
Quote:
|
All times are GMT -5. The time now is 02:58 AM. |