Is there a way to remove spaces in filenames in quantities?
Is there some sort of find and replace option to accomplish this
in explorer (my computer)?
I have downloaded a number of images with spaces.
example
Starting;
pict one sideways.jpg
pict two sideways.jpg
pict three sideways.jpg
pict four sideways.jpg
pict five sideways.jpg
"giddyup" <nospam@nospam.com> wrote in message
news:ujr27nXUIHA.6060@TK2MSFTNGP05.phx.gbl...
> Is there a way to remove spaces in filenames in quantities?
> Is there some sort of find and replace option to accomplish this
> in explorer (my computer)?
>
> I have downloaded a number of images with spaces.
>
> example
> Starting;
>
> pict one sideways.jpg
> pict two sideways.jpg
> pict three sideways.jpg
> pict four sideways.jpg
> pict five sideways.jpg
>
> Finishing;
>
> pictonesideways.jpg
> picttwosideways.jpg
> pictthreesideways.jpg
> pictfoursideways.jpg
> pictfivesideways.jpg
>
> I have hundreds of these to do and the web hosting requires no spaces
> help!!!
>
> Thanks
I don't think that Explorer has the tools to do this. Here is a way
to do it with a batch file. Copy & past the lines below into a file
called "NoSpaces.bat" which you must store in the same folder
where your .jpg files reside.
@echo off
setlocal EnableDelayedExpansion
set active=no
set mode=rem
if "%active%"=="yes" set mode=if
dir /b *.txt > "%temp%\dir.txt"
for /F "delims=" %%a in ('type "%temp%\dir.txt"') do (
set old=%%a
set new=!old: =!
if not "!old!"=="!new!" echo ren "!old!" "!new!"
%mode% not "!old!"=="!new!" ren "!old!" "!new!"
)
echo.
echo Press the Space Bar to close this window.
pause > nul
Now use Explorer to navigate to your .jpg folder, then
double-click "Spaces.bat". You will see what the batch
file would do if it was activated.
To activate the batch file, change Line 3 to
set active=yes
(lower case, no additional spaces!)
Now run the batch file again!
giddyup wrote:
>
> Is there a way to remove spaces in filenames in quantities?
> Is there some sort of find and replace option to accomplish this
> in explorer (my computer)?
As an aside. One does NOT want spaces in filenames, as the spaces can be
a "non-dos" character.
Pegasus (MVP) wrote:
> "giddyup" <nospam@nospam.com> wrote in message
> news:ujr27nXUIHA.6060@TK2MSFTNGP05.phx.gbl...
>> Is there a way to remove spaces in filenames in quantities?
>> Is there some sort of find and replace option to accomplish this
>> in explorer (my computer)?
>>
>> I have downloaded a number of images with spaces.
>>
>> example
>> Starting;
>>
>> pict one sideways.jpg
>> pict two sideways.jpg
>> pict three sideways.jpg
>> pict four sideways.jpg
>> pict five sideways.jpg
>>
>> Finishing;
>>
>> pictonesideways.jpg
>> picttwosideways.jpg
>> pictthreesideways.jpg
>> pictfoursideways.jpg
>> pictfivesideways.jpg
>>
>> I have hundreds of these to do and the web hosting requires no spaces
>> help!!!
>>
>> Thanks
>
> I don't think that Explorer has the tools to do this. Here is a way
> to do it with a batch file. Copy & past the lines below into a file
> called "NoSpaces.bat" which you must store in the same folder
> where your .jpg files reside.
>
> @echo off
> setlocal EnableDelayedExpansion
> set active=no
>
> set mode=rem
> if "%active%"=="yes" set mode=if
> dir /b *.txt > "%temp%\dir.txt"
> for /F "delims=" %%a in ('type "%temp%\dir.txt"') do (
> set old=%%a
> set new=!old: =!
> if not "!old!"=="!new!" echo ren "!old!" "!new!"
> %mode% not "!old!"=="!new!" ren "!old!" "!new!"
> )
> echo.
> echo Press the Space Bar to close this window.
> pause > nul
>
> Now use Explorer to navigate to your .jpg folder, then
> double-click "Spaces.bat". You will see what the batch
> file would do if it was activated.
>
> To activate the batch file, change Line 3 to
> set active=yes
> (lower case, no additional spaces!)
> Now run the batch file again!
>
>
Thanks,
I will do a test try on that. I appreciate the quick response as well.
"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
news:u1NYVTYUIHA.1212@TK2MSFTNGP05.phx.gbl...
> ...
> 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.
"VanguardLH" <VanguardLH@mail.invalid> wrote in message
news:6audnThIJpkaPx7anZ2dnUVZ_jednZ2d@comcast.com. ..
> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
> news:u1NYVTYUIHA.1212@TK2MSFTNGP05.phx.gbl...
>> ...
>> 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!
"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.
"VanguardLH" <VanguardLH@mail.invalid> wrote in message
news8qdnVI24OYDTh7anZ2dnUVZ_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.