What is the best way to verify if the daily file was created? I wasn’t sure how to get the DateTime information interpolated into the file query given format of the filename so my current approach is something like
This works but I was just wondering if this was the best approach? The more I browse the posts on this site the more I realize there are generally much smarter ways of doing things.
Because sorting such string alphanumerically is the same as sorting by date and there is no ambiguity about the month and day components (which is which). Any other format is sowing the seeds of chaos.
Thanks so much guys! This is why posting on this forum is incredibly helpful.
@Dan really appreciate your example. I checked the docs first but got confused and was using DateFormat which kept returning an error. Your example really clarifies that DateFormat converts type string to type Date and Dates.format() does the reverse by converting type Date to type string. It makes a lot more sense now thanks!
@Henrique_Becker Thanks so much for pointing that out. It’s another thing I would not have thought of. There’s already an existing cache of files named in this manner but I will keep this in mind going forward.
Before you change over to ISO8601 (a suggestion I wholeheartedly agree with), change all the old files doing something like
inreg = r"(\d{2})-(\d{2})-(\d{2})"
outreg = s"20\3-\1-\2"
for f in readdir("folder"; join=true)
isnothing(match(inreg, f)) && continue
mv(f, replace(f, inreg=>outreg))
end
wow thanks this is brilliant! It would’ve taken me like seven hours to figure this out. I hope you don’t mind if I make some notes here just for future reference and anyone else who may be new to this. But if it is distractingly elementary for, or not useful to the discourse I’ll delete it.