我怎么可以编写一个脚本(自动执行此过程)的找位,并在文件名的特殊字符。我在SVN文件名的大数据 [英] How can i write a script (to automate this process) that find spaces and special character in file name. I have large data of filename in SVN
本文介绍了我怎么可以编写一个脚本(自动执行此过程)的找位,并在文件名的特殊字符。我在SVN文件名的大数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
find.型F | egrep的-I!〜||&放大器; | @ |#|< |> |; |:| |'^'|,| - | _| T恤TEMP.TXT
find.-type f|egrep-i"~||&|@|#|<|>|;|:|!|'^'|,|-|_"|tee temp.txt
我不知道特殊字符,如*或$。你能帮我了这一点。
I am not sure about special characters like * or $. Can you help me out with this.
推荐答案
首先,我建议写一个脚本,它接受一个文件名,并修复它。然后,你可以这样做:
First of all, I'd suggest to write a script which takes a single file name and fixes it. Then you can do:
find . -type f -exec /path/to/fixNames.sh "{}" \;
fixNames.sh
则可能包含:
rename 's/[ \t]/-/' "$1" # blanks
rename "s/'\",//" "$1" # characters to remove
rename 's/&/-n-/' "$1"
请注意:测试此与一些不好的文件名的文件夹!只有当你知道,这不会导致问题,运行此对真正的文件!
Note: Test this with a folder with some bad file names! Only run this against the real files when you know that this doesn't cause problems!
相关阅读:
- Introduction to shell scripting
这篇关于我怎么可以编写一个脚本(自动执行此过程)的找位,并在文件名的特殊字符。我在SVN文件名的大数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文