Type sequential numbers into file names

I’m saving webpages in Safari as web archives to a Finder folder. The name of the web archives in the save dialogue window come up as the same word each time and can not simply be saved as such as it will replace the previous one given they are going into the same new folder each day. I therefore need to type a number at the end of the file name to save them in sequence.

My thought is to have a macro that triggered would add a sequential number to the end of the file name. Alternatively, a macro that let me define a root name and add a number to the end would work.

The counter could simply start at 1 and be incremented each time it is triggered. A bit of fanciness would be to have the starting number be settable so to continue numbering on later occasions. As of now each day gets a new folder to save the webpages in so I don’t need to worry about reading the names of the files already in the folder which seems like a lot more work.

Once this function is available, I will add the bits to the workflow to automate as much as possible around saving webpages.

Thank you for your assistance.

It's actually easier than keeping -- and keeping in sync -- a global variable.

All you need to do is check the target folder to see if eg filename.txt exists -- if not, save filename.txt. If filename.txt does exist then add the base suffix of your choice between the name and extension, eg filename-01.txt. test again, and increment the number until a file with that name doesn't exits -- you can then save using that name.

Check the "Path" condition if you want to go this route.

But...

Why bother? If you always append a current date and time stamp to the name when you save you'll be fine unless you create archives with the same base name with less than a 1 second interval. Format your stamp correctly and you'll maintain an alphabetic sort order that matches the save-time order. You wouldn't even need "daily" folders as the date would be included in the name.

Something like %ICUDateTime%yyyy-MM-dd_hh-mm-ss% would do the trick.

1 Like

Thank you. That was the missing thinking I needed.

A date and time stamp is sufficient and the outline to checking the target folder content is clear.

Date stamps are one of the most useful ways of doing such things - especially for versioning documents for example - way better than "filename new newer newest final 3.txt".

2 Likes