rename file with progressive enumeration

送分小仙女□ 提交于 2019-12-25 16:45:28

问题


I have a file called mycat.avi inside a folder VIDEO so that the path is c:\video\mycat.avi

now I would like rename it so that the new re-name become start from C0700.mxf

IF in folder c:\video is jet present another C0700.mxf -----> the file have to renamed C0701.mxf

if in folder c:\video is jet present another C0701.mxf -----> the file have to renamed C0702.mxf

if in folder c:\video is jet present another C0702.mxf -----> the file have to renamed C0703.mxf

... and so on

Supposing mycat.avi become renamed as C0716.mxf (so that now is present as c:\video\C0716.mxf)

--> after the renaming operation, tha batch have to create a .avs file (located alwais in the c:\video folder) that are called mycat_is_C0716.avs that contains:

FFVideoSource("c:\video\C0716.mxf")

So finally, in c:\video are present only this files: C0716.mxf and mycat_is_C0716.avs

Thanks


回答1:


Test this:

@echo off
cd /d "c:\video"
for /L %%a in (0700,1,9999) do (
   if exist "mycat.avi" if not exist "C%%a.mxf" (
      ren "mycat.avi" "C%%a.mxf"
      >"mycat_is_C%%a.avs" echo FFVideoSource^("c:\video\C%%a.mxf"^)
   )
)
pause


来源:https://stackoverflow.com/questions/26160804/rename-file-with-progressive-enumeration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!