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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.