gpt4 book ai didi

Git:一次重命名或移动所有文件

转载 作者:IT王子 更新时间:2023-10-29 00:35:12 26 4
gpt4 key购买 nike

我想将我的 Git 项目中的所有 erb 文件重命名为 haml。(例如将 index.html.erb 重命名为 index.html.haml)

如果我重命名每个文件,我必须输入以下命令三十多次。

$ git mv app/views/pages/index.html.erb app/views/pages/index.html.haml

我试过下面的命令,但没有用。

$ git mv app/views/**/*.erb app/views/**/*.haml

usage: git mv [options] <source>... <destination>

-n, --dry-run dry run
-f, --force force move/rename even if target exists
-k skip move/rename errors

如何立即重命名它们?

最佳答案

for i in $(find . -iname "*.erb"); do
git mv "$i" "$(echo $i | rev | cut -d '.' -f 2- | rev).haml";
done

对于每个 .erb 文件,git mv 将扩展名“.erb”替换为“.haml”。

关于Git:一次重命名或移动所有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9151920/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com