File.Find Filters

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • yhb
    Forum Member
    • Sep 2007
    • 74

    File.Find Filters

    Is it posibble to use a filter for File.Find ? like if I want to find only (*aa.pdf, *.bb.pdf, *cc.pdf) instead of using a wildcard like below?

    File.Find(tFolder, "*.*", false, false, nil, nil);

    Thanks much... :

    yhb
  • ShadowUK
    No longer a forum member
    • Oct 2007
    • 1322

    #2
    Something like *.file?*.lulz

    Don't think that works.

    Comment

    • TimeSurfer
      Forum Member
      • Dec 2007
      • 479

      #3
      its possible but youd have to use regex in lua or use my free dll RegXmATCH. I was working on a similar type of project some time ago to create a custom compression application and needed to filter the file types.

      Comment

      • ShadowUK
        No longer a forum member
        • Oct 2007
        • 1322

        #4
        Originally posted by AutoPlay Media Studio 7.0 Help
        Filename
        (string) The name of the file that you want to search for. You can use the * and ? wildcards in this field to search for files that match a specific pattern.
        You can use wildcards, no need for a DLL.

        Comment

        • pem
          New Member
          • Dec 2007
          • 21

          #5
          hi yhb

          hi yhb and all. i write some func maybe these can help you :

          Global Functions:
          Code:
          function DelimitedStringToTable(DelimitedString, Delimiter)
          	tbReturn = {};
          	local strWorking;
          	local nPos = nil;
          	local strData;
          	local nTableIndex = 1;
          	local nDelimiterLength = String.Length(Delimiter);
          	
          	if(nDelimiterLength < 1)then
          		tbReturn[nTableIndex] = DelimitedString;
          		return tbReturn;
          	end
          	
          	strWorking = DelimitedString;
          	nPos = String.Find(strWorking,Delimiter);
          	while(nPos ~= -1)do
          		strData = String.Left(strWorking,nPos-1);
          		tbReturn[nTableIndex] = strData;
          		nTableIndex = nTableIndex + 1;
          		local nLength = String.Length(strWorking);
          		strWorking = String.Right(strWorking,nLength - (nPos + (nDelimiterLength-1)));
          		nPos = String.Find(strWorking,Delimiter);
          	end
          	if(strWorking ~= "")then
          		tbReturn[nTableIndex] = strWorking;
          	end
          	
          	return tbReturn;
          end
          
          
          function FilesFind (files, drives)
          
          a = 0
          my_table = DelimitedStringToTable(files, "|")
          fix = DelimitedStringToTable(drives, "|")
          allfolder_files = {}
          
          for count,drive in fix do
             
             for index,file in my_table do
              foundfile = File.Find(drive, file, true, false, nil, nil);
          
               if (foundfile ~= nil) then 
                
                for f,g in foundfile do
                 a=a+1
                 Table.Insert(allfolder_files, a, g);
                end
               
               end
             
             end
          
          end
          
          	return allfolder_files
          end

          for call this func you must write files with | for first parameter an Folders with | for Second parameter. for example :
          Code:
          tbl = FilesFind ("*.pdf*|*.exe*|*.bmp*|*a.avi", "g:\\pdfs|f:")
          
          for a,b in tbl do
          	ListBox.AddItem("ListBox1", b, "")
          end
          in this examp search *.pdf* and *.exe* and *.bmp* and *a.avi in g:\pdfs and f:\

          Enjoy.

          Comment

          • ShadowUK
            No longer a forum member
            • Oct 2007
            • 1322

            #6
            I think it's just *.file,*.fileext2 or *.ext|*.lol

            Comment

            • TimeSurfer
              Forum Member
              • Dec 2007
              • 479

              #7
              Originally posted by ShadowUK View Post
              You can use wildcards, no need for a DLL.
              hey shadow i found the only reason i needed to use regex was for to filter multiple file extensions for the same type of file and perform an action based upon it. [mainly for imagelist]

              Like when u have spanned rar files such as .rar, .r01, .r02, ect

              Comment

              • yhb
                Forum Member
                • Sep 2007
                • 74

                #8
                Hey PEM, Thank you so much.... it works GREAT. Exactly what I'm looking for. I appreciate this a lot.

                Thank you again..

                yhb

                Comment

                Working...
                X