通过重新排列原始文件名来重命名多个文件 [英] Renaming multiple files by rearranging the original file name
本文介绍了通过重新排列原始文件名来重命名多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想重命名遵循相同命名约定的多个文件,唯一的变化是名称末尾的日期.
I want to rename multiple files that follow the same naming convention, the only variation is the date at the end of the name.
例如TRADARCASHROLLUP.GRPTIRHK.01052017.CSV
我希望文件的新名称以日期开头,而不是01052017.TRADARCASHROLLUP.GRPTIRHK.CSV
For example TRADARCASHROLLUP.GRPTIRHK.01052017.CSV
I would like the new name of the file to begin with the date instead 01052017.TRADARCASHROLLUP.GRPTIRHK.CSV
希望有人可以帮助我编写批处理脚本来实现这一目标.我看到了其他答案,但无法将其应用于此.
Was hoping someone could help me write a batch script to achieve this. I have seen other answers but not been able to apply them to this.
我尝试使用以下内容:
ls | %{ "C:\UBSTesting\Incoming\TRADARCASHROLLUP.GRPTIRHK*" $_.name ($_.name
-replace '^(\w+).(\w+).(\w+)', '$3.$1.$2')}
推荐答案
,也将其标记为batch-file
:
@echo off
setlocal enabledelayedexpansion
for %%a in (*.*.*.csv) do (
for %%b in (%%~na) do (
set new=%%~xb.%%~nb%%~xa
ECHO !new:~1!
)
)
这篇关于通过重新排列原始文件名来重命名多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文