如何在Windows 10上使用git以相同的格式更改多个文件名?

问题描述 投票:1回答:1

我有数百个名为tutorial_xx.cpp的文件,其中xx是1到99之间的数字。我达到了三位数的标记,现在我必须更改所有文件编号,以便我可以跟踪时间顺序。我想,如果我可以在0tutorial_之间添加xx.cpp,我可以实现这一点,但显然这不起作用:

git mv tutorial_*.cpp tutorial_0*.cpp

是否有可能成功地在git中做这样的事情?如果是这样,怎么样?

git multiple-files mv
1个回答
4
投票

如果在git-bash中,您可以尝试:

for name in tutorial_*.cpp;do
    git mv $name ${name/_/_0/}
done

如果安装了Python,请尝试:

python -c "import os;map(lambda x:os.rename(x,x.replace('_','_0',1)),filter(lambda x:'tutorial_' in x, os.listdir('.')))"
© www.soinside.com 2019 - 2024. All rights reserved.