Highlighted
Absent Member.
Absent Member.
274 views

[archive] Deleting Files

[Migrated content. Thread originally posted on 01 May 2008]

Hello, again
Is there any way in Acucobol to delete all files in a folder?
Thanks
0 Likes
4 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Deleting Files

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
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Deleting Files

Thanks, Shaun
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Deleting Files

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
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Deleting Files

Thanks for your help, Shaun
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.