批处理文件 - 重命名和增量夹号码? [英] BATCH File - Rename and Incremental folder number?
问题描述
我撞了南墙有一个BAT文件我试图做。
这是我的文件结构。
C:\\视频\\ **
这个文件我已经各种各样的文件/文件夹,某些文件夹内开始 AB **
(即 **
是一个四位数字),我要重命名ARCHIVEAB **
这是我能做到与此: -
为/ D %% f由于(C:\\视频\\ AB *)做重命名%% FARCHIVE〜%%〜NXF
我的问题是,视频文件夹将始终以相同的AB号终于重新填充,我想是,如果AB号重新出现将是该文件有一些摆在它前面的顺序 - 所以我最终会喜欢的东西。
ARCHIVEAB1234
1ARCHIVEAB1234
和如果另一个AB123文件出现那么这将成为
ARCHIVEAB1234
1ARCHIVEAB1234
2ARCHIVEAB1234
任何指针?
@ECHO OFF
SETLOCAL
针对/ D %% f由于(\\ AB1 *)做(
如果不存在ARCHIVE〜%%〜NXF(
SET reqren = Y
FOR / L %%倍In(1,1,999)DO如果定义reqren IF NOT存在%% xARCHIVE〜%%〜NXF(重命名%% F%% xARCHIVE〜%%〜NXF&放大器; SET reqren =)
)ELSE(重命名%% FARCHIVE〜%%〜NXF)
)
GOTO:EOF
应该看到这个问题了。您可能要修改(1,1,999)
到(100,1,999)
来preserve的目录名-length一致性。
I've hit a brick wall with a BAT file i'm trying to make.
This is my file structure..
c:\video\ **
within this file I have various files/folders, some folders start AB**
(THE **
IS A FOUR DIGIT NUMBER) which I want to rename ARCHIVEAB**
which I can do with this :-
for /D %%f in (C:\video\AB*) do rename "%%f" "ARCHIVE~%%~nxf"
My issue is that the video folder will always repopulate eventually with the same AB number, what I would like is if the AB number re-appeared would be for the file to have a number put in front of it sequentially - so I would end up with something like..
ARCHIVEAB1234
1ARCHIVEAB1234
and if another AB123 file appeared it would then become
ARCHIVEAB1234
1ARCHIVEAB1234
2ARCHIVEAB1234
Any pointers?
@ECHO OFF
SETLOCAL
for /D %%f in (.\AB1*) do (
IF EXIST "ARCHIVE~%%~nxf" (
SET reqren=Y
FOR /l %%x IN (1,1,999) DO IF DEFINED reqren IF NOT EXIST "%%xARCHIVE~%%~nxf" (rename "%%f" "%%xARCHIVE~%%~nxf"&SET "reqren=")
) ELSE (rename "%%f" "ARCHIVE~%%~nxf")
)
GOTO :EOF
should see this problem off. You might want to change the (1,1,999)
to (100,1,999)
to preserve the directoryname-length consistency.
这篇关于批处理文件 - 重命名和增量夹号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!