Source: http://superuser.com/questions/16007/how-can-i-mass-rename-files-from-the-command-line-or-using-a-3rd-party-tool
Thanks to zdan of superuser.com
tl;dr? Here’s the script:
dir /B > fileList.txt
for /f “tokens=1,2,3,4,5 delims=-” %i in (fileList.txt) DO ren “%i-%j-%k-%l-%m” “%i-flowers-%l-%m”
rm fileList.txt
Enjoy. Now for the curious, read on.
What those commands do are as follows:
Now, the way the loop works is really cool, and I mean REALLY cool. Here’s what happens:
So, now we can gather what info the script is using:
Tokens: 5, %i, %j, %k, %l, %m
Delimiters: -
Current File Name Pattern: “%i-%j-%k-%l-%m”
Desired File Name Pattern: “%i-flowers-%l-%m”
Now we know, after that close look at what the command does, that the script is using 5 tokens, what their variables are, how it’s delimiting the file name, what the file name pattern currently is, and how it will be renamed. I told you it was neat. It certainly makes life easier when you’re handed a batch of files improperly renamed ever-so-slightly. :) Enjoy.
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Apr | ||||||
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | |||