[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文件操作] 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.

版主给翻译下白?

TOP

好东西,刚好在找类似工具,一上来就有收获,感谢分享!

TOP

2# tmplinshi


catch you

TOP

返回列表