Loop through files in a folder
#1

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?
Reply
#2

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.
Reply
#3

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, ...).
Reply
#4

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.
Reply
#5

There's an index number for each file in y_files in a directory IIRC, you can use it to loop through every file.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)