Linux (bash) find all files import first found to the next line of some code and rename and repeat

105 Views Asked by At

How do I find all files within a folder with this condition "someting".mp4 import it to the next command and in next I import the modified name of the file (a renamed version of the found file) like so "something"_Fast.mp4 into another part of the command?

Something like this:

Repeat until there are no files left.    
Find all files containing condition "someting".mp4
Program_name.py --input_file "something".mp4 --output_file "something"_Fast.mp4

Also, it must not pick freshly created files.

1

There are 1 best solutions below

2
On

Example, that accepts any character for the filename, even LineFieeds and other white spaces. Directory $FOLDER is searched recursively. Replace it by . for the current directory.

find "$FOLDER" -type f -name '*.mp4' -print0 |
  while IFS= read -r -d $'\0' file
  do 
    echo "$file"
    Program_name.py --input_file "$file" --output_file "${file%.mp4}_Fast.mp4"
  done