Re: Removing spaces in filenames by Pegasus
Pegasus
Tue Jan 08 12:27:09 PST 2008
"VanguardLH" <VanguardLH@mail.invalid> wrote in message
news:p8qdnVI24OYDTh7anZ2dnUVZ_gGdnZ2d@comcast.com...
> "Pegasus (MVP)" wrote in message
> news:OLBO4phUIHA.6060@TK2MSFTNGP05.phx.gbl...
>>
>> "VanguardLH" wrote ...
>>>
>>> "Pegasus (MVP)" wrote ...
>>>>
>>>> ...
>>>> for /F "delims=" %%a in ('type "%temp%\dir.txt"') do (
>>>> ...
>>>
>>> Um, wouldn't there be a space character after the equals sign for the
>>> delims parameter, as in "delims= "? Otherwise, you are not specifying
>>> any delimiter character(s).
>>>
>>> I didn't proof the rest of the script. This just jumped out at me as I
>>> scanned through the script.
>>
>> Good point. I spotted the same thing too while monitoring a batch
>> newsgroup and realised that someone had stumbled on a feature
>> that is probably undocumented but works very nicely. Using the
>> "delim=" syntax means "there are no delimiters", hence the variable
>> %%a will be set to the whole string, no matter what it contains -
>> which is exactly what we want!
>
> Ah, I didn't notice the line:
>
> set new=!old: =!
>
> where you were taking out the spaces from the string. That is, after the
> colon delimiter from the variable name, you have the space character
> equaling a null character, so the string gets the spaces removed. On my
> first glance, I thought you were going to walk through the string using
> the for-loop to remove spaces but the 'set' command is faster.
Correct. And yes, the string substitution method is much, much faster
than a looping method. However, your method based on joining the
individual tokens to a single string would probably work just as fast.