You can use the -exec
option of find
. Here, '{}'
is replaced with the file name of every MP4 file. This will deal with all kinds of file names, even those containing spaces or newlines. You need to supply -maxdepth 1
to only search the current directory.
find . -iname "*.mp4" -maxdepth 1 -exec mp4box -inter 500 '{}' \;
An alternative, more convoluted way would involve piping the output from find
into a loop with read
. Here, every file is delimited by the NUL
character, and you need to tell read
to split the input on this character, which is achieved by -d ''
. You also need to quote the variable "$file"
, so spaces or globbing characters in the name are retained.
find . -iname "*.mp4" -maxdepth 1 -print0 | while IFS= read -d '' -r file; do mp4box -inter 500 "$file"; done