Page 1 of 1

Wildcards???

Posted: Wed Nov 12, 2003 7:51 pm
by Mr Tickle
Hi,

I would like to move all the *.txt files from 1 dir to another. I'm using the RenameFile() command which works fine for single named files( RenameFile("C:\Temp\FileA.txt", "C:\Temp\FileB.txt") ).

Is there a way to use wildcards? (*.*, *.zip, *.txt etc) If not can anyone suggest a workaround? I have a comboboxgadget to select the appropriate wildcard.

Thanks in advance.

Posted: Wed Nov 12, 2003 7:54 pm
by Pupil
Why not use 'examinedirectory()' to get the files from source folder?

Posted: Fri Nov 14, 2003 3:16 pm
by Mr Tickle
Thanks Pupil, Works a treat ;)

Code: Select all

    If ExamineDirectory(0, File$, Filter$)   ; going to examine the dir For selected files
      n = NextDirectoryEntry()      ; this returns TRUE if there is a NEXT *.dta file
      While n
         filename$ = DirectoryEntryName() ; get the CURRENTLY found filename only - not path
         n = NextDirectoryEntry()  ; try to find another file with same type (Filter$)
         RenameFile(Source$ + filename$, Dest$ + filename$)
      Wend
   EndIf
I thought I'd post the snippet incase it's useful to anyone else.