Daily file naming sequence reset

Started by MW4, February 09, 2016, 12:09:41 PM

Previous topic - Next topic

MW4

Hello everyone,
I use the "How to Watch for Files and Then Do Something" on a server to process files as they come in.
Normally there is only one file per day which makes processing easy because there is a set file name and no other files arrive as processing occurs.

I have a new requirement for multiple files in a day and the possibility that files will come in as a process is working.
I need to name in a sequential fashion as files come in every day like T1.txt, T2.txt, T3.txt so I can process sequentially and look for the next sequenced file.

I can set the Variable to increment as files come in, but what would be the best way to reset to 1 at midnight?

Hopefully this is not too convoluted of an explanation.

JTaylor

What if you just used

   file_name = "t":StrReplace(TimeYmdHms(),":",""):".txt"

to create the name.  They will sort properly and you don't have to worry about resetting.

Jim

MW4

The processing reaches out in sequence to process in the order that they came in.

Presently I'm using a variation of what you suggested, but I'd like to get it in the format of T1, etc

I have a few uses for a daily resettable variable, so I'd like to find a solution for that.

JTaylor

With each loop save the time (not date part) and whenever the new time is less than the saved time reset your counter.

Jim

MW4


....IFICantBYTE

Watch out for Daylight Saving if it affects your area... the time will go back an hour and if a file came in then and it was less than an hour since the last one, then the new time will be older than the saved time!
If you use Universal time then it shouldn't be an issue.
Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

MW4

these files wouldn't come in at those hours, it's only 9-5 business hours, but good point!