How to quickly rename my files?

Hi,

I have a subdirectory with a 1000 files in it named:

sub-directory /files2
1000.utf
1001.utf
1002.utf

etc

1999.utf

I need to rename them to the same names less 1000

so they become:~

0.utf
1.utf
2.utf

etc

999.utf

What would be the best way to do this in a simple php script
that will step through the sub-directory files ?

Thanks

http://php.net/rename

By the look of it you could use glob() to retrieve a list of files and then process them, or opendir() and scandir() to read through the directory. Either would allow you to retrieve all the names, then you can loop through each one, split the name, deduct the 1000 from the first part, rebuild the new name, then rename the file. If you already know the filenames you could just loop and rename, my preference though would be to base it on what’s there.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.