mooner Posted May 12 Report Posted May 12 Hi everyone, I have a question: Suppose there's a folder containing a large number of PNG images — say, around 10,000 files. What's the best way to get the name of the most recently created or modified image in that folder? Is there a faster method? Quote
Neil Pate Posted May 12 Report Posted May 12 Have you tried this? The `last mod` output should hopefully give you the timestamp of the last modification, and it would then be pretty simple to find the latest. I have no idea what the performance of this would be if you loop over 10000 files. That is something you would just have to try. Quote
Neil Pate Posted May 12 Report Posted May 12 Done some simple testing. On a directory containing 838 files it took 60 ms. 1 Quote
hooovahh Posted May 12 Report Posted May 12 3 hours ago, Neil Pate said: Done some simple testing. On a directory containing 838 files it took 60 ms. That's how I'd do it. Then combine that with the Foreign Key Sort from my Array package, putting the Time Stamps into the Keys, then paths into the Arrays, and it will sort the paths from oldest to newest. Reverse the array and index at 0, or use Delete From Array to get the last element, which would be the newest file. 1 Quote
dadreamer Posted May 12 Report Posted May 12 In addition to the LV native method, there are options with .NET and command prompt: Get Recently Modified Files. 1 Quote
Neil Pate Posted May 12 Report Posted May 12 I also realised I messed up my benchmark and the final High Precision Time should be after the sorting. I meant to do this just forgot! Quote
hooovahh Posted May 12 Report Posted May 12 38 minutes ago, dadreamer said: In addition to the LV native method, there are options with .NET and command prompt: Get Recently Modified Files. If you are in a Windows environment, and have many files to process, this is probably going to be faster. There probably are several factors in determining when doing this in .NET is the better solution. Quote
ShaunR Posted May 12 Report Posted May 12 39 minutes ago, dadreamer said: In addition to the LV native method, there are options with .NET and command prompt: Get Recently Modified Files. Heathen My go. Last Mod.vi Quote
Neil Pate Posted May 12 Report Posted May 12 23 minutes ago, ShaunR said: Heathen 16.37 kB · 0 downloads 😂😂😂 Quote
mooner Posted May 13 Author Report Posted May 13 Thanks for everyone’s guidance. I ran my tests, and the performance is within an acceptable range for now. That said, if there are any smarter or more efficient approaches I could try, I’d definitely love to hear them Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.