I'm cleaning up thousands of filenames, most have a structure like: "xxxx xxxx - xxxxx xxxx xxxx.yyy" The problem is that some are capitalized and some are not. (Actually there are other problems too, but I can fix those easily.)
I would like to take a string of any characters, and capitalize all of it's words before any period.
Preferably using a single line of code, using pipes, rather than using files, like you can do with FIND.
Lastly I would prefer to just capitalize the entire string at once, but I'm not opposed to handling each word separately.
Example:
Input: "this - string IS an EXAMPLE 4 u"
Output: "This - String IS An EXAMPLE 4 U"
I want to ignore all upper-case and non-alphabetic characters (dashes, underscores, numbers, etc), just pass them through unaffected.
So I would like to be able to use code like this (the 2nd line is the relevant one):
for /f "tokens=*" %%x in ('dir /b *.zzz') do (
for /f "tokens=*" %%y in ('echo %%x ^| findstr /r "s/\s\w/\U$&/g;"') do (
rename "%%x" "%%y" ))
If possible, I would like to be able to test it on the command-line like this:
echo hello to you | findstr /r "s/\s\w/\U$&/g;"
My problem is that the above example does not provide any output.
As you can see, I have searched for examples of regular expressions, but can't get them to plug-and-play with findstr.
I'd rather not capitalize the file extention, but this is easily fixed, so I don't really care.
Please no sed, grep, or any other 3rd party software suggestions, though I would be open to other MS-based solutions (something that comes with Enterprise or Ultimate or downloadable from Microsoft).
Thanks in advance!