I better fess-up on my newbieness; I know less than you think.
For the first proposed solution above (thanks to Helpmeh and Salmon Trout), do I just type it into a DOS emulator, or is it more involved?
Keep in mind that I want this to go through a few hundred files and make this change to them all (swap an underscore for a space).
Ghostdog, there are no instances of multiple underscores, but I would want them replaced by a single space.
I tried to identify the elements of the above solution so as to educate myself.
Below is a line-by-line explanation. Is my understanding correct?
setlocal enabledelayedexpansion - the activity of the command will be kept to a specified folder
for /f "delims=" %%A in (*.txt) do - 'for' is like an "IF" command, but I don't know what /f does.
- I don't get the "delims=" either.
- Are the percentage signs are wildcards?
- I know that *.txt means 'all text files'
set oldname=%%A - does this specify the format of the old name?
set newname=!oldname:_= ! - this makes sense (I think), it changes the underscore to a space
ren "!oldname!" "!newname!" - this renames the file, with the new (underscoreless) name
Thank you for your insight and patience,
Honestly, you understood very well for a beginner. I'll just confirm and fix what you said about the script:
Setlocal enabledelayedexpansion I'm not exactly sure what this means, but regular variables in for commands are wrapped in ! and not %.
"Delims=" That means that there are no delimiters (things that seperate the information) to be used.
%%a (or %%A) That is a FOR variable. It is only used in the FOR command. For every line of data, it will become that. So if a line was file_name.txt, then %%a would become file_name.txt .
in (*.txt) That is where the data comes from. For each file, there is a new line. * is a wildcard. If you knew how long the desired file is, you can use a certain amount of ? (question marks are a 1-character wildcard).
Set oldfilename=%%a Doing that allows me to work with the name.
Set newfilename=!oldfilename:_= ! That will make newfilename the same as oldfilename, but every _ becomes a space.
Ren !oldfilename! !newfilename! Pretty explanitory.
Understand a little better now?