Results 11 to 20 of 21
-
7th Jan 2012, 03:46 PM #11OPMember
Yep i was using the previous code , $files instead of $folder
Its working now but its giving the full location , needed the foldername only but it might be possible to use the full location as well in the script , will have to mess with it a bit
Thanks again for your help
-
7th Jan 2012, 03:51 PM #12Respected MemberWebsite's:
DL4Everything.com Soft2050.inWell, if the fullname doesn't works out, then you can even get the directory name only
You have to use php's basename() function for that: http://php.net/manual/en/function.basename.php
PHP Code:echo basename("folder/My folder"); //outputs My folder
-
7th Jan 2012, 05:46 PM #13OPMember
Zip hit another glitch ,
Soft2050 method is working tho giving the full filelocation .
I need to rename folderx as well , remove empty spaces e.g :
"The Folder X" > "The.Folder.X"
$folder = array();
foreach (glob("$location*") as $thefolder) {
If (is_dir($thefolder)) {
$folder[] = $thefolder;
$folderx = $folder[0];
}
}
Is there any additional code i can add for this ?
when i run the above code i get : /location/The Folder X
-
7th Jan 2012, 05:52 PM #14Respected MemberWebsite's:
DL4Everything.com Soft2050.inThe above reply does the same for getting the name It will do the work for you
For replace ., str_replace would jut work fine: http://php.net/manual/en/function.str-replace.php
PHP Code:$folder = array();
foreach (glob("$location*") as $thefolder) {
If (is_dir($thefolder)) {
$folder[] = $thefolder;
$folderx = str_replace(' ', '.', basename($folder[0]));
}
}
-
7th Jan 2012, 05:54 PM #15OPMember
between you sure it will rename the folder itself or only the variable ?
Edit : tested ( it only removes the spaces in the variable , not the folder itself )
-
7th Jan 2012, 05:57 PM #16Respected MemberWebsite's:
DL4Everything.com Soft2050.inOOpz! Didn't knew you need to rename the folder too:
For renaming, use rename() : http://php.net/manual/en/function.rename.php
PHP Code:foreach (glob("$location*") as $thefolder) {
If (is_dir($thefolder)) {
$folderx = str_replace(' ', '.', basename($thefolder));
rename($thefolder, str_replace(' ', '.', $thefolder);
break; // Breaks next loops since we only need 1
}
}
-
7th Jan 2012, 06:22 PM #17OPMember
-
7th Jan 2012, 06:28 PM #18Respected MemberWebsite's:
DL4Everything.com Soft2050.inAdd the end bracket before ;
PHP Code:rename($thefolder, str_replace(' ', '.', $thefolder));
-
7th Jan 2012, 06:46 PM #19OPMember
Nearly working 100% :
foreach (glob("$location*") as $thefolder) {
If (is_dir($thefolder)) {
rename($thefolder, str_replace(' ', '.', $thefolder));
$folderx = $thefolder;
break; // Breaks next loops since we only need 1
}
}
echo $folderx;
now the actual folder is renamed to The.Folder.X but $folderx is still returning = "/location/The Folder X"
-
7th Jan 2012, 10:40 PM #20MemberPHP Code:
foreach (glob("$location*") as $thefolder) {
if (is_dir($thefolder)) {
$folderx=str_replace(' ', '.', $thefolder)
rename($thefolder, $folderx);
break; // Breaks next loops since we only need 1
}
}
echo $folderx;
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Mass rar each folder
By Ruriko in forum Technical Help Desk SupportReplies: 1Last Post: 11th Aug 2012, 01:24 PM -
Problem with folder.
By sasa037 in forum Technical Help Desk SupportReplies: 4Last Post: 25th Dec 2011, 06:42 AM -
Track Folder Changes
By Daniel in forum Webmaster ResourcesReplies: 0Last Post: 3rd Nov 2011, 02:06 PM -
VPS Folder Permissions.
By Trueno22 in forum Server ManagementReplies: 8Last Post: 23rd Aug 2010, 09:59 PM -
[WTS] Database Folder.
By Luke in forum Completed TransactionsReplies: 3Last Post: 20th Sep 2009, 05:01 PM
themaCreator - create posts from...
Version 3.08 released. Open older version (or...