首页 > 解决方案 > Linux(bash) find all files import first find to the next line of some code and rename and repeat

问题描述

如何在此条件下找到文件夹中的所有文件"someting".mp4将其导入下一个命令,然后我将修改后的文件名称(找到的文件的重命名版本)像这样"something"_Fast.mp4导入命令的另一部分?

像这样的东西:

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

此外,它不能选择新创建的文件。

标签: linuxbashgnome-terminal

解决方案


例如,它接受文件名的任何字符,甚至 LineFieeds 和其他空格。$FOLDER递归搜索目录。将其替换.为当前目录。

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

推荐阅读