Loop through files in a folder - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Loop through files in a folder (
/showthread.php?tid=304770)
Loop through files in a folder -
RelaxCafe - 19.12.2011
OK, there are 1000+ account files in the uSers folder with different nick names.. Now my question is how do I loop through all of them without knowing the file's name? I am saying, look through all 1000 of them and check if the last sign in date is 3 months older that today's day and destroy the file? Is it possible to do that kind of thing?
Re: Loop through files in a folder -
CaHbKo - 19.12.2011
There is no functionality like that in PAWN, however you could utilize the Execute (
https://sampforum.blast.hk/showthread.php?tid=100177) plugin and use that cool batch language. Or create a simple program on VB, C++ or .bat and just execute that one.
Re: Loop through files in a folder -
Sinner - 19.12.2011
Quote:
Originally Posted by RelaxCafe
OK, there are 1000+ account files in the uSers folder with different nick names.. Now my question is how do I loop through all of them without knowing the file's name? I am saying, look through all 1000 of them and check if the last sign in date is 3 months older that today's day and destroy the file? Is it possible to do that kind of thing?
|
Looping through folders has always been a hassle with these file writing/reading systems. If you would use a database system to store your account you could loop through all your users in the blink of an eye (MySQL, SQLLite, ...).
Re: Loop through files in a folder -
Gamer_Z - 19.12.2011
well since you are stuck with files now I recommend importing everything to a database or the easier method:
use y_files (******'s file plugin) , there is a function to get the directory listing as long as I remember, never used it though.
Re: Loop through files in a folder -
Calgon - 19.12.2011
There's an index number for each file in y_files in a directory IIRC, you can use it to loop through every file.