batch rename files

<?xml version="1.0" encoding="utf-8"?> batch rename files

batch rename files

Command Prompt

You can use the rename – or ren – DOS command in a Command Prompt window to rename multiple files at once. It accepts the wildcard character – * – to match multiple files. The quickest way to open a Command Prompt window at your desired location is to hold Shift, right-click in the folder, and select “Open command window here.”

The most obvious use case for the rename command is changing multiple file extensions at once – something you can’t do in Windows Explorer. The following command will rename all .html files in the current folder to .txt files:

ren *.html *.txt

This command doesn’t offer a lot of power on its own, although it can be integrated into more complex batch scripts.

PowerShell

PowerShell offers much more flexibility for renaming files in a command-line environment. Using PowerShell, you can pipe the output of one command – known as a “commandlet” in PowerShell terms — to another command, just like you can on Linux and other UNIX-like systems.

The two important commands you’ll need are Dir, which lists the files in the current directory, and Rename-Item, which renames an item (a file, in this case). Pipe the output of Dir to Rename-Item and you’re in business.

After you launch PowerShell, use the cd command to enter the directory containing your files. You should put the files in their own directory so you don’t accidentally rename other files.

Dir | Rename-Item –NewName { $_.name –replace “ “,”_” }

Replace the “ “ and “ parts of the command to replace other characters in file names.


Post by: Jalen Wang (转载请注明出处)

转载于:https://www.cnblogs.com/jalenwang/archive/2013/03/04/2943083.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值