gte Posted November 6, 2009 Posted November 6, 2009 Right now I am using the following code, but I feel like filefindfirstfile is a sloppy way to do this, in case the first file is not a zip file or an xml file, and neither is the second or third. I could use if _filelisttoarray with a wild card I think but again that seems a little sloppy, but maybe there is a way to use if fileexists with a wild card? if FileFindFirstFile(guictrlread($downloadbaklocation_box) & "\*.zip") = 1 Then RunWait(@WindowsDir & '\temp\7zip\7za.exe x ' & guictrlread($downloadbaklocation_box) & '\*.zip *.xml -oc:\temp\testxmls') Else $didnotfindzipfiles = 1 MsgBox(0, "Error", "There are no .zip files in that folder") EndIf if FileFindFirstFile(guictrlread($downloadbaklocation_box) & "\*.xml") = 1 Then _countdocsinnotif Else $didnotfindxmlfiles = 1 MsgBox(0, "Error", "There are no .xml files in that folder") EndIf Thanks for reading. HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script
PsaltyDS Posted November 6, 2009 Posted November 6, 2009 (edited) FileFindFirstFile() does not just check the first file in the directory. It returns a search handle when it finds the first MATCHING file. If it doesn't find one, it returns -1. So this is a test for *zip files: $hSearch = FileFindFirstFile("C:\Temp\*.zip") If $hSearch = -1 Then ConsoleWrite("No zip files." & @LF) Else $sName = FileFindNextFile($hSearch) ConsoleWrite("First zip file: " & $sName & @LF) EndIf FileClose($hSearch) Edited November 6, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
AdmiralAlkex Posted November 6, 2009 Posted November 6, 2009 Did you even try doing it yourself first? It didn't take me many hours minutes seconds to write this two-liner to test if FileExist supports wild cards:$iTest = FileExists("F:\*.mp3") ConsoleWrite(@error & "/" & VarGetType($iTest) & "/" & $iTest & @CRLF)(and it works!) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
gte Posted November 7, 2009 Author Posted November 7, 2009 Yes, I tried this, I'll have to look at my code and figure out why it failed Did you even try doing it yourself first? It didn't take me many hours minutes seconds to write this two-liner to test if FileExist supports wild cards: $iTest = FileExists("F:\*.mp3") ConsoleWrite(@error & "/" & VarGetType($iTest) & "/" & $iTest & @CRLF) (and it works!) HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script
gte Posted November 7, 2009 Author Posted November 7, 2009 Thanks Psalty FileFindFirstFile() does not just check the first file in the directory. It returns a search handle when it finds the first MATCHING file. If it doesn't find one, it returns -1. So this is a test for *zip files: $hSearch = FileFindFirstFile("C:\Temp\*.zip") If $hSearch = -1 Then ConsoleWrite("No zip files." & @LF) Else $sName = FileFindNextFile($hSearch) ConsoleWrite("First zip file: " & $sName & @LF) EndIf FileClose($hSearch) HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script
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