Activity Stream
48,167 MEMBERS
62069 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21
  1.     
    #11
    Member
    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






  2.   Sponsored Links

  3.     
    #12
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    Well, 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 
    You could even use the pathinfo : http://www.php.net/manual/en/function.pathinfo.php and its filename or basename

  4.     
    #13
    Member
    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








  5.     
    #14
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    The 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]));
        }


  6.     
    #15
    Member
    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 )






  7.     
    #16
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    OOpz! 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($thefolderstr_replace(' ''.'$thefolder);
            break; 
    // Breaks next loops since we only need 1
        
    }

    I have removed the array part since you don't really need it.

  8.     
    #17
    Member







  9.     
    #18
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    Add the end bracket before ;

    PHP Code: 
    rename($thefolderstr_replace(' ''.'$thefolder)); 

  10.     
    #19
    Member
    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"






  11.     
    #20
    Member
    PHP 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

Page 2 of 3 FirstFirst 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Mass rar each folder
    By Ruriko in forum Technical Help Desk Support
    Replies: 1
    Last Post: 11th Aug 2012, 01:24 PM
  2. Problem with folder.
    By sasa037 in forum Technical Help Desk Support
    Replies: 4
    Last Post: 25th Dec 2011, 06:42 AM
  3. Track Folder Changes
    By Daniel in forum Webmaster Resources
    Replies: 0
    Last Post: 3rd Nov 2011, 02:06 PM
  4. VPS Folder Permissions.
    By Trueno22 in forum Server Management
    Replies: 8
    Last Post: 23rd Aug 2010, 09:59 PM
  5. [WTS] Database Folder.
    By Luke in forum Completed Transactions
    Replies: 3
    Last Post: 20th Sep 2009, 05:01 PM

Tags for this Thread

BE SOCIAL