linux递归重命名文件名

时间:2020-08-03 00:45:53

标签: linux bash file-rename mv

我需要将 bash-sdl2-compile.sh 递归重命名为 compile.sh
尝试使用“重命名”失败,很明显,安全功能不允许使用“ bash”一词,即

find ./ -name "bash-sdl2-compile.sh" -print0 | xargs -0 rename "bash-sdl2-compile.sh" "bash-sdl2-compile/compile"

错误消息:在(用户提供的代码)使用“ strict subs”时,不允许标语“ bash”。 xargs:重命名:以状态255退出;流产

如何递归重命名linux文件?

    dir1
       |_project1
                |_ bash-sdl2-compile.sh
    dir2
       |_project2
                |_ bash-sdl2-compile.sh
    dir3
       |_project3
                |_ bash-sdl2-compile.sh
  . . . 

因此,将每个“ bash-sdl2-compile.sh”重命名为“ compile.sh”

1 个答案:

答案 0 :(得分:1)

无需使用xargsfind就足够了:

find . -name bash-sdl2-compile.sh -execdir mv -i {} compile.sh ";"

(尝试此操作之前,请备份整个树)

相关问题