Skip to main content

[archive] Deleting Files

  • May 1, 2008
  • 5 replies
  • 0 views

[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

5 replies

[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
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

[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
Thanks, Shaun

[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
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

[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
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

[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
Thanks for your help, Shaun