【问题标题】:I would like to append the name of a bunch of files automatically.我想自动附加一堆文件的名称。
【发布时间】:2015-05-20 05:56:17
【问题描述】:

我想附加一堆文件的名称。 Windows 7。我的文件都有这种名称格式:NNNNNNN_NNNNN.tif。我希望将它们更改为 111_NNNNNNN_NNNNN.tif。我可以使用 bat 文件或脚本来执行此操作吗?

【问题讨论】:

  • 您能否更具体地说明您希望前缀的外观?你想要连续的整数吗?

标签: file batch-file append names


【解决方案1】:

如果您的意思是使用迭代器重命名文件,那么使用 powershell 可以(可能不需要 $() 进行强制解释):

Dir *.tif | ForEach-Object -begin { $i=111 } -process { Rename-Item $_ -NewName "$($i)_$($_).tif"; $i++ } 

批量:

@echo off

set i=111

for %%f in (*.tif) do call :renamefiles "%%f"
goto done

:renamefiles
ren %i_%1%.tif
set /A i+=1

:done

【讨论】:

    猜你喜欢
    • 2020-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-29
    • 2019-11-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多