安排自动文件名更改

时间:2014-11-12 17:04:03

标签: automation scheduled-tasks batch-rename

我正在尝试安排任务来编辑图像的名称。图像从123-1234.jpg到123_1234.jpg例如。

这就是我现在所拥有的。

powershell.exe -noexit -command "cd'C:\path\i\want" Get-ChildItem -Filter "*.jpg" -Recurse | Rename-Item -NewName {$_.name -replace "-", "_" }

感谢帮助。

我需要这个代码的原因是我有1个软件可以生成各种扩展的图像,但命名文件的方式就像这样12345-123456.jpg

其他软件我有这样的进口名称,如12345_123456.jpg。

这可以解决我需要第三方软件的问题,如果我可以创建一个自动化任务,只需将目录中的所有.jpg更改为自动导入所需的名称格式。

1 个答案:

答案 0 :(得分:0)

powershell.exe -noexit -command Get-ChildItem 'C:\my\file\path\' -Filter "*.jpg" -Recurse | Rename-Item -NewName {$_.name -replace '-','_' }

我为自己感到自豪,因为这是我第一次使用Powershell。这很好。