raven096 Posted July 4, 2005 Share Posted July 4, 2005 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 More sharing options...
GaryFrost Posted July 4, 2005 Share Posted July 4, 2005 (edited) Look up StringInStr in the help If StringInStr($filesearch, 'Hello') then ; do what you need to do endif Edited July 4, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
raven096 Posted July 4, 2005 Author Share Posted July 4, 2005 (edited) 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 July 4, 2005 by raven096 Link to comment Share on other sites More sharing options...
LxP Posted July 4, 2005 Share Posted July 4, 2005 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 More sharing options...
drak Posted July 4, 2005 Share Posted July 4, 2005 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now