我在一个目录中有大约50个文件,其中包含空格、撇号等。我如何对它们进行批量重命名,以删除撇号并用下划线替换空格?
我能做到
ls | grep '*.txt' | xargs ....但是我不知道在xargs中该怎么做
发布于 2011-04-12 12:14:00
我使用的是ren-regexp,它是一个Perl脚本,让您可以非常轻松地对文件进行批量重命名。
你会做像ren-regexp 's/ /_/g' *.txt这样的事情。
$ ls -l
total 16
-rw-r--r-- 1 marc marc 7 Apr 11 21:18 That's a wrap.txt
-rw-r--r-- 1 marc marc 6 Apr 11 21:18 What's the time.txt
$ ren-regexp "s/\'//g" "s/ /_/g" *.txt
That's a wrap.txt
1 Thats a wrap.txt
2 Thats_a_wrap.txt
What's the time.txt
1 Whats the time.txt
2 Whats_the_time.txt
$ ls -l
total 16
-rw-r--r-- 1 marc marc 7 Apr 11 21:18 Thats_a_wrap.txt
-rw-r--r-- 1 marc marc 6 Apr 11 21:18 Whats_the_time.txthttps://stackoverflow.com/questions/5630310
复制相似问题