Announcement

Collapse
No announcement yet.

Script to Change Directory Names

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script to Change Directory Names

    Hi,

    I have a script that creates folders for my members to upload pics to, but I initially wrote the script to create folders based on usernames. This has become a problem because many users have characters that really shouldn't be in a url and sometimes members request username changes, so I'd like to alter the directories and scripts to use the userid instead.

    What I want to do pull up each member that has a vehicle in the system, then alter their directory from the username to the userid to avoid these problems in the future.

    How can I run the command to alter the directory from a php script? I basically want to run:

    mv 'username' 'userid'

    Can php run this command, or are their functions that will do this for me instead?

    Thanks,

    Mark

  • #2
    I found a rename function for php. Can I use:
    Code:
    // query for all users that have a vehicle in the registry
    // goes here
    while($userInfo=$DB_site->fetch_array($queryResults)) {
    chdir('/abs/path/to/images')
    rename($userInfo[username],$userInfo[userid]);
    }
    Thanks,

    Mark

    Comment

    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
    Working...
    X