?
Solved

PHP Remove space in folder name on server

Posted on 2010-01-10
8
Medium Priority
?
364 Views
Last Modified: 2013-12-13
hi
I ahve a bunch of folders like

folder a
folder b

On my server

I need to remove the space in bewteen so
foldera
folderb

Any ideas how I can do that?
Cheers
Mat
0
Comment
Question by:funkkube
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26279024
How many such folders?  You might just use FTP and rename them.  That's what I would try.
0
 

Author Comment

by:funkkube
ID: 26279044
about 2000... :-)
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26279057
That's a lot!  Have you tried using this?
http://us2.php.net/manual/en/function.rename.php
0
WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

 
LVL 82

Expert Comment

by:leakim971
ID: 26279220
Hello funkkube,

Why PHP ? If you have a shell : http://techgurulive.com/2008/09/22/how-to-remove-spaces-from-filenames-linux/

Regards

0
 
LVL 11

Accepted Solution

by:
VanHackman earned 2000 total points
ID: 26279426
I coded the functional script to do it,
I tried and works perfectly, if you want to rename files too
just remove this part of the condition: "&& (is_dir($path."/".$file))"

Bye!

<?php

//Rename Removing Spaces in Folders By VanHackman

$path = "your/directory";

$Dir = opendir($path); 

while ($file = readdir($Dir))
{

   if ($file != '.' && $file != '..' && (is_dir($path."/".$file)))
   { 

	  $NewName = str_replace(' ','',$file);
	  rename($path."/".$file, $path."/".$NewName);

   } 

}

closedir($Dir); 

?>

Open in new window

0
 

Author Comment

by:funkkube
ID: 26279534
Excellent!
Worked a treat!
Thanks!!
0
 

Author Closing Comment

by:funkkube
ID: 31675256
top banana!
0
 
LVL 11

Expert Comment

by:VanHackman
ID: 26279583
Your Welcome.
Thanks for the points.
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question