Use ADIR to get specific files from a folder

Chdir(SOURCE_FILE_DIR)
numfiles=
Adir
(filearry)


I know you get files that have a specific extension like this: Adir(filearry, '*.TXT')
BUT can you use a negative condition with Adir

Example: get files from a folder where the extension is not .txt or .dat



Answer this question

Use ADIR to get specific files from a folder

  • MalamisuraE

    Or, since you are most likely going to be using your filearray in a looping structure to process the files in some fashion, why not forego it altogether and use SYS(2000, *.*, [1]) and LOOP on the ones you don't want to process.  I'm thinking it would be faster and more powerful than using the Adir() and then having to remove or forego array elements you don't want.  However, I don't know what problem you are trying to solve here and I haven't run any speed tests.  Consider it my best "guess-timate".

  • RMarmion

    Before I made the post I was thinking along the same lines as Craig B about removing items from the array.

    What I ended up doing:

    Loop through the file array

    IF (ALLTRIM(JUSTEXT(filearry[cntr,1])) <> EXT_1) AND (ALLTRIM(JUSTEXT(filearry[cntr,1])) <> EXT_2)

    ** PROCESS FILE HERE
    ENDIF

    Thanks for taking the time to reply.


  • syeager

    No, ADIR() doesn't support that. You could get all the files, then loop through the array and delete any rows that you don't want.

  • Use ADIR to get specific files from a folder