Large scale file moving

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Large scale file moving

Post by s.dot »

There's about 5000 directories in one of my directories, and each one of those 5,000 directories could contain up to a couple hundred photos.

Currently they're stored as the username

/user1/
/user2/
/user3/

etc.

I'm going to be renaming them to the users id, then moving them to a new location

newdir/1/
newdir/2/
newdir/3/

And then transfering the contents.

What's the best way to do this?

Obviously a gigantic loop comes to mind, but I have not had good experiences with huge loops. =[
What about taring the directory, and untaring to the new location, and just running a script to rename? Rename and move at once? copy() or rename()?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

How about doing it with Bash script rather than PHP?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

More comfortable with the browser than a shell doing something this important.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply