Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

PHP Remove space in folder name on server

Posted on 2010-01-10
8
Medium Priority
?
373 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
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 83

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
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.
Suggested Courses

564 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