|
The Claptain posted:Hello Goons, I have two problems I'd appreciate some input on. you say that you want to keep the last 5, not keep them based on some property of the dates themselves; and they are in YYYY-WW format. so why not just compare the strings? you don't need to turn them into dates to do what you describe. they will compare the correct way lexicographically
|
# ¿ Apr 3, 2023 10:55 |
|
|
# ¿ May 14, 2024 19:45 |
|
Pile Of Garbage posted:Genuinely interested, what environment are you in where that is a compatibility issue? Windows and POSIX has no issues with files and folders having the same name, what monstrosity are you using which doesn't? ??????
|
# ¿ May 25, 2023 20:38 |
|
Being mistaken happens to the best of us. Yes I think I would agree and generalise what you're saying as: it is useful to keep in mind the need to be aware whether you're testing for existence of files, directories, or both. One reason is to want to know whether a filesystem object is created and is specifically a directory, so (ignoring security for the moment) you would expect to be able to create things inside it. I'm more likely to be writing C# than Powershell code, and using Directory.Exists() or File.Exists(). But there too I might want to check both, to avoid leaving the silly edge case where I test whether a directory existed, and it didn't, but the program will still blow up when I try to create the directory because a file existed with that name.
|
# ¿ May 25, 2023 21:28 |