I am new on linux and I want to make a loop on file to do the same command on all files in a folder, the command include the file name:
ffmpeg -i REC_2019_08_31_11_52_30_F.MP4 REC_2019_08_31_11_52_30_F.ass
I tried with
for f in files do ''command'' done
but it didn't work.
Best Answer
A
for
loop converting every.MP4
file in the current directory with Parameter Expansion for the file extension change would look like this:${i/%MP4/ass}
expands to the currently processed filename with the last occurence of “MP4” replaced by “ass”. Another way of achieving the same is to cut the string from the last dot and add the new extension:${i%.*}.ass
In a case of multiple, probably lasting operations like this I really like to use GNU
parallel
, which by running jobs in parallel can highly increase the speed. The above loop withparallel
would simply be: