Jump to content

Loop and increment filename


wiggst3r

Recommended Posts

Hi

 

I have a script that adds files to a folder, that I get from FTP.

I download these files everyday and are txt files, but are iin CSV format.

 

In this folder I currently have 3 files. 1.csv, 2.csv and 3.csv

 

Rather than me renaming them everyday, I'm looking to write a script to auto-increment the filename.

 

So i'm looking to loop through the files in the folder, If there is no filename which is 4.csv, the file that has been downloaded will be renamed to this.

The next day, the file will be renamed to 5.csv etc

 

Does anyone know the code to do this?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/111507-loop-and-increment-filename/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.