Jump to content

File Name Filter Search


Recommended Posts

I'm new to AutoIt so I need some help here, I'm looking for a way to look for a word within a file name, it might be in the beginning, middle or end of the file:

Hello*.*

*Hello*.*

*Hello.*

I've found some file searches based on a mask but not a full name. If I was writing in perl I'd just:

$filesearch =~ /Hello/i;

But I'm trying to create a GUI interface and I find AutoIt much easier to build in, so if anyone has a suggestion or a function it would be very helpful.

Link to comment
Share on other sites

Sorry, I guess what I really am looking for is a function to search a directory for a file with a specific word within the filename thats also not case sensitive.

Edited by raven096
Link to comment
Share on other sites

Sorry, I guess what I really am looking for is a function to search a directory for a file with a specific word within the filename thats also not case sensitive.

You could use FileFindFirstFile() and FileFindNextFile() to build a list of files within a specified directory and then search each line of the list for a substring.

Alternatively you could call DOS to do this for you (untested; may need to edit slightly):

local $fileSpec = "C:\My Folder\*apple*"
local $tempFile = @tempDir & "\listing.txt"

runWait(@comSpec & '/c dir /b /s "' & $fileSpec & '" > "' & $tempFile & '"', "", @SW_HIDE)

; code to process the listing would go here

fileDelete($tempFile)

Regards,

Alex Peters

Link to comment
Share on other sites

this works well:

$AllPcFiles = FileFindFirstFile("\\server\log$\AdminAudit\*.txt")

While 1
   $filename = FileFindNextFile($AllPcFiles)
   If @error Then ExitLoop
   If $filename = "" Then ExitLoop
   $FileRead = Fileopen("\\server\log$\AdminAudit\" & $filename, 0) 
  ; do what ever here
   FileClose($fileRead)
WEnd
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...