I've looked and looked, and I can not see how to do this...
I need a list of files in a specific directory with a specific extension. And I need to be able to fill and array with the file names.
for example:
I need a list of all the files in c:\myprogram with the file extension *.m_p
and I need that list put into an array file_names$(500)
Can someone point me in the right direction?
Thanks,
Mike...
files in a specific directory with a specific extension
Re: files in a specific directory with a specific extension
have a look to the parameter "Pattern$" of ExamineDirectory()
Re: files in a specific directory with a specific extension
You mean like this, using a structured list:
Code: Select all
Structure Files
; using a structured list allows us to store more than one bit of information per item
; Right now I only want to store a name and an item number
name.s
number.i
EndStructure
NewList file.Files()
Count=0
Directory$ = "c:\myprog" ; Change this to your path
Debug Directory$
With File() ; Start using our list
If ExamineDirectory(0, Directory$, "*.m_p") ; change the extension
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
Filename$ = DirectoryEntryName(0)
AddElement(file()) ; and an element
Count+1
\name=Filename$ ; adds a name
\number=count ; adds the count number
EndIf
Wend
FinishDirectory(0)
EndIf
EndWith
ResetList(File()) ; Go to the beginning of our list
Debug "Found "+Str(Count)+" file(s)"
ForEach File()
Debug Str(file()\number)+Space(10)+file()\name
Delay(50)
Next
Last edited by em_uk on Mon Jun 24, 2013 10:32 pm, edited 1 time in total.
----
R Tape loading error, 0:1
R Tape loading error, 0:1
Re: files in a specific directory with a specific extension
Or if answering your request correctly using an array :
Code: Select all
Dim File_names$(500)
Count=0
Directory$ = "c:\myprog" ; Change this to your path
Debug Directory$
If ExamineDirectory(0, Directory$, "*.m_p") ; change the extension
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
Count+1
File_names$(Count)=Filename$
EndIf
Debug DirectoryEntryName(0) + Type$ + "- Size in byte: " + Str(DirectoryEntrySize(0))
Wend
FinishDirectory(0)
EndIf
Debug "Found "+Str(Count)+" file(s)"
For files=1 To Count
Debug Str(files)+Space(10)+File_names$(files)
Next
----
R Tape loading error, 0:1
R Tape loading error, 0:1