View Full Version : Deleting Files
Milk5600
05-01-2008, 09:24 AM
Hello, again
Is there any way in Acucobol to delete all files in a folder?
Thanks
Shaun
05-01-2008, 09:56 AM
Yeah.
You need to use C$LIST-DIRECTORY
We have routines that are ran via unix cron jobs every 10 minutes looking for certain files in a directory.
We then process the files and then delete them after we're done.
I can get you some sample code if you need it, but its not that difficult.
Shaun
Milk5600
05-01-2008, 09:59 AM
Thanks, Shaun
Shaun
05-02-2008, 12:47 AM
Some code as mentioned which will let you see what we do.
PATTERN in my case is "SPCK????????.dat"
Make sure the directory exists
CALL "C$LIST-DIRECTORY"
USING LISTDIR-OPEN, WS-PRM-W1-IMPORT-DIRECTORY, PATTERN
MOVE RETURN-CODE TO MYDIR
IF MYDIR = 0
CALL "C$LIST-DIRECTORY" USING LISTDIR-CLOSE, MYDIR
SET WS-PANIC TO TRUE
END-IF
END-IF.
IF NOT WS-PANIC
PERFORM MAIN-LOOP THRU MAIN-LOOP-EXIT
UNTIL WS-THATS-ALL
END-IF.
In the main loop we just keep processing filenames returned
PERFORM WITH TEST AFTER UNTIL FILENAME = SPACES
CALL "C$LIST-DIRECTORY"
USING LISTDIR-NEXT, MYDIR, FILENAME
IF FILENAME NOT = SPACES
We do all the processing and then just delete the file when done
END-IF
END-PERFORM
CALL "C$LIST-DIRECTORY" USING LISTDIR-CLOSE, MYDIR
SET WS-THATS-ALL TO TRUE.
Shaun
Milk5600
05-02-2008, 03:40 AM
Thanks for your help, Shaun
vBulletin® v3.6.8, Copyright ©2000-2010, Jelsoft Enterprises Ltd.