Setlocal EnableExtensions DisableDelayedExpansionįor /F "eol=| delims=" %%I in ('dir /A-D-H /B 2^>nul ^| %SystemRoot%\System32\findstr.exe /R /C:"19" /C:"20"') do call :RenameFile "%%I" Well, in real I use Total Commander for nearly all file management tasks.īut it was interesting to develop the code for this very special file renaming task with all the limitations Windows command processor has because of not being designed for such tasks. I use since more than 20 years Total Commander (shareware) for file/folder renaming tasks which makes it possible with its built-in multi-rename tool to easily rename files and folders with just a few clicks on which the results can be viewed before really running the multi-rename and which even supports undo after having done the multi-rename. So I can output a list of matching file names, but from there I do not know how to target the grouped characters that findstr matched in order to parse the full file name into the 3 chunks I believe I would need: the substring preceding the matched group, the group itself, and the substring following the group. So far, I have only been able to match the file names containing a year string with the following code: off Notice that if it's already wrapped in parentheses, I'd prefer not to double them up. In a windows batch file, I would like to rename files containing a 4-digit year (ex: "1999") in the filename by simply wrapping the year string in parentheses.
0 Comments
Leave a Reply. |