How can I (from cmdline!) rename parts of filename (and leave the remaining part untouched)?
Simplified example:
Assume I have the following files:
test aabb cc 13412542552.pdf
second aabb cc 324236236.pdf
other aabb cc 2345325.pdf
Now I want to replace the pattern " aabb cc " by " (newpattern 2019) " so that the filenames are as follows:
test (newpattern 2019) 13412542552.pdf
second (newpattern 2019) 324236236.pdf
other (newpattern 2019) 2345325.pdf
Possible other files should be renamed accordingly.
Keep in mind that a file like:
norename-aabb cc 356345634.pdf
should NOT be renamed (mind the enclosing blanks!).
How can I achieve this (in general)?
If necessary a (free), simple, third party cmdline tool is acceptable.
No difficult regular expressions are necessary.
Peter
How to rename parts of filenames with certain target patterns?
Moderator: DosItHelp
Re: How to rename parts of filenames with certain target patterns?
Then the line below requires to navigate to the target folder beforehand.(from cmdline!)
Note I suppose "from cmdline" meant to be "not from within a Batch script".
I use FINDSTR which doesn't support difficult regular expressions anyway. So It's very basic regex.No difficult regular expressions
Code: Select all
for /f "delims=" %i in ('dir /a-d /b *.pdf^|findstr /rixc:"[^ ][^ ]* [^ ][^ ]* [^ ][^ ]* [0-9][0-9]*\.pdf"') do @for /f "tokens=1,4" %j in ("%i") do @ECHO "%i" "%j (newpattern 2019) %k"
Steffen