HTFC Forums

H.T.F.C.

How To Fix Computers





Go Back   HTFC Forums > Software Newsgroups > Windows XP

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1  
Old 01-07-2008, 10:09 PM
giddyup
 
Posts: n/a
Default Removing spaces in filenames

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
Reply With Quote
Sponsored Links
Fix your Windows Problems - FAST.
FREE Safe Scan Registry Check. Locate & Fix Errors in Minutes!
  #2  
Old 01-07-2008, 11:27 PM
Pegasus \(MVP\)
 
Posts: n/a
Default Re: Removing spaces in filenames


"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!


Reply With Quote
  #3  
Old 01-08-2008, 06:49 AM
Plato
 
Posts: n/a
Default Re: Removing spaces in filenames

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.






--
http://www.bootdisk.com/

Reply With Quote
  #4  
Old 01-08-2008, 03:32 PM
giddyup
 
Posts: n/a
Default Re: Removing spaces in filenames

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.
Reply With Quote
  #5  
Old 01-08-2008, 04:19 PM
VanguardLH
 
Posts: n/a
Default Re: Removing spaces in filenames

"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.

Reply With Quote
  #6  
Old 01-08-2008, 05:18 PM
Pegasus \(MVP\)
 
Posts: n/a
Default Re: Removing spaces in filenames


"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!


Reply With Quote
  #7  
Old 01-08-2008, 07:48 PM
VanguardLH
 
Posts: n/a
Default Re: Removing spaces in filenames

"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.

Reply With Quote
  #8  
Old 01-08-2008, 08:27 PM
Pegasus \(MVP\)
 
Posts: n/a
Default Re: Removing spaces in filenames


"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.


Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I recover some lost files when the partition has few spaces? smith Windows XP 0 12-06-2007 12:36 PM
Windows Live Spaces churin Windows Vista 0 08-23-2007 01:56 AM
Unwanted spaces in numbered lists bonochick Microsoft Office 0 05-24-2007 06:47 PM
time in making task bar take up two vertical spaces marcy Windows XP 4 05-21-2007 02:07 AM
Mail Merge- how to prevent non breaking spaces tc Microsoft Office 0 05-06-2007 12:06 PM


All times are GMT. The time now is 04:50 PM.


Powered by vBulletin® Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© 2004 - 2007 Web-S-Sense Pty. Ltd. Usenet and forums posts © their respective authors.
Ad Management by RedTyger