通过更改前缀来重命名一组文件
我有一组四个目录,
English.lproj
German.lproj
French.lproj
Italian.lprj
每个目录都包含一系列 XML,名为
2_symbol.xml
4_symbol.xml
5_symbol.xml
... and so on ...
I need to rename all of those files into 另一个数字模式, 因为确定这些数字的代码已经改变。 所以新的数字模式就像这样
1_symbol.xml
5_symnol.xml
3_symbol.xml
... and so on ...
,没有适用于确定这个系列的算法,因为这个 我考虑将两个数字系列存储到数组中的原因。
我正在考虑使用简单的 bash 脚本快速完成此操作。 我认为我需要一个数组来存储旧的数字模式和另一个 数组来存储新的数字模式,以便我可以执行一个循环来提出
# move n_symbol.xml newdir/newval_symbol.xml
任何建议?
谢谢,干杯。
-k-
I've got a set of four directories
English.lproj
German.lproj
French.lproj
Italian.lprj
each of this contains a serie of XMLs named
2_symbol.xml
4_symbol.xml
5_symbol.xml
... and so on ...
I need to rename all of these files into another numerical pattern,
because the code that determined those numbers have changed.
so the new numerical pattern would be like
1_symbol.xml
5_symnol.xml
3_symbol.xml
... and so on ...
so there's no algorithm applicable to determine this serie, because of this
reason I thought about storing the two numerical series into an array.
I was thinking to a quick way of doing it with a simple bash script.
I think that I'd need an array to store the old numerical pattern and another
array to store the new numerical pattern, so that I can perform a cycle to make
# move n_symbol.xml newdir/newval_symbol.xml
any suggestion?
thx n cheers.
-k-
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为此,您不需要 bash,任何 POSIX 兼容的 shell 都可以。
编辑:您需要注意覆盖文件。例如,上面的代码片段 clobbers 4_symbol.xml。
you don't need bash for this, any POSIX-compatible shell will do.
edit: you need to take care of overwriting files. the snippet above clobbers 4_symbol.xml, for example.
以下脚本将随机调整“lproj”目录中所有 xml 文件的符号名称。
注意:当您对结果满意时,删除
mv
前面的echo
并重新运行脚本使更改永久生效。脚本输出
The following script will randomly shuffle the symbol names of all xml files across 'lproj' directories.
Note: Remove the
echo
in front of themv
when you are satisfied with the results and re-run the script to make the changes permanent.Script Output