Board logo

标题: [文件操作] bkren - 用正则表达式重命名文件 [打印本页]

作者: tmplinshi    时间: 2011-7-11 16:02     标题: bkren - 用正则表达式重命名文件

http://bcn.bathome.net/s/tool/index.html?key=bkren

BK Renamer 1.0
--------------

BK Renamer is a command-line utility that allows you to perform
mass renaming of files based on a UNIX-style regular expression.



Installation
------------

Copy the file "bkren.exe" to somewhere in the system path.



Use
---

The syntax of BK Renamer is as follows:

  bkren [-s] "searchexpression" "replaceexpression"

If the "-s" (subdirectories) switch is specified, the program will
recurse and process all subdirectories along with the current
directory. If not specified, the program only processes the files
and folders in the current directory.

The "searchexpression" is a regular expression that determines
which filenames/foldernames are going to be renamed.

The "replaceexpression" is a replacement regular expression that
determines what the filenames/foldernames are changed to.



Examples
--------

bkren "(.*)\.htm" "\1.html"
  (Change all files/folders in the current directory with the .htm
   extension to have the .html extension.)

bkren "(.*)\.([^.]*)" "\1_backup.\2"
  (Appends _backup to all filenames, but before the file extension.
   For example, changes bkren.txt to bkren_backup.txt and test.html
   to test_backup.html. Note that we've put quotes around each
   argument. This is *required* in some situations, so it's a good
   idea to use quotes if you're not sure.)

bkren -s "(.*)100(.*)" "\1303\2"
  (This go through all filenames in the current directory and all
   subdirectories and change all instances of "100" in these
   filenames to "303". For example it would change bkren100.zip
   to bkren303.zip. It would also change 100monkeys.gif to
   303monkeys.gif.)



Warranty
--------

There isn't any. Make backups. Lots of them.



Contact
-------

If you do find any bugs or want to contact the author for any other
reason, please feel free to write to Bill Klein <[email]bill@orbit.org[/email]>.
Also note that the latest version of the program can always be found
at:

  http://www.orbit.org/renamer/


发现有时候同一个文件会被重命名多次。例如:

e:\我的文档\桌面>bkren "(.*)(-)(.*\.txt)" "\1 - \3"
2-3.txt   -->   2 - 3.txt
2 - 3.txt   -->   2  -  3.txt


另一个类似工具 ren2 也有这个问题:
e:\我的文档\桌面>ren2 -f "(.*)(-)(.*\.txt)" "\1 - \3"
"2-3.txt" changed to "2 - 3.txt"
"2 - 3.txt" changed to "2  -  3.txt"

From Chris Lomont 2006. See www.lomont.org for updates.

作者: CrLf    时间: 2011-7-11 17:04

2# tmplinshi


catch you
作者: strong12345    时间: 2011-7-16 04:17

好东西,刚好在找类似工具,一上来就有收获,感谢分享!
作者: sxw    时间: 2011-7-17 13:13

版主给翻译下白?




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2