eliminating spaces for folder name

kaz4541

n00b
Joined
Oct 4, 2009
Messages
27
Hi. I am trying to upload files from cute ftp to the web. The problem is, all of the folders have spaces in the name. Is there a way to rename the whole batch? I have found a program that will rename files, but not folders. I've also found a program to rename folders, but it will only change the name, but not eliminate spaces.
 
If you're on Windows 7, this PowerShell script should do it (by it I mean replace only folder [including hidden ones] names' spaces with _s in the current directory):

Get-ChildItem * -force | Where-Object {$_.mode -match "d"} | ForEach-Object {$file = $_.Name; $file = ($file).replace(" ","_"); Rename-Item $_.FullName $file }
 
No. I am using Windows XP. I was using Windows 7, but didn't like it, so I deleted it. I will keep that in mind in case I am ever on a Windows 7 computer. Thanks.
 
Powershell is an optional download from Microsoft Update for Windows XP. Or directly from Microsoft.com. Then you could use Snowknight26's previous suggestion.
 
Batch file:

Code:
@echo off
for /r /d %%A in (*.*) do (
set folder=%%A
call :action
)
goto:eof
:action
echo ren "%folder%" "%folder: =%
goto:eof

There. Fixed it for folders instead of files. I really should read more often. That will walk the entire directory tree down from the folder you put the batch file in and remove all the spaces from the folder names.
 
Last edited:
Back
Top