Dizzy Posted June 23, 2005 Posted June 23, 2005 Hi! I was looking on my disk for a special type of a file. The extension was case sensitive. For example: firstfile.STE firstfile2.ste Now i want to search for all file with the UPPER xxtension *.STE. Result: firstfile.STE The normal search function in XP failed and i haven't found a freeware which offers the correct result. I just get both or no files in the result. Thanks for help or scripts.
ezzetabi Posted June 23, 2005 Posted June 23, 2005 (edited) Probably not the best solution, but it is the only I can think. Use _FileSearch to look for *.ste, it will return in the array both CAPS and non caps results. When you have to work on the files use a CASE sensitive StringInStr expandcollapse popup$Files = _FileSearch('d:\test\*.ste') For $c = 1 to $Files[0] If StringInStr($Files[$c], '.STE', 1, -1) Then ;Your job here EndIf Next Exit Func _FileSearch($sIstr) ; An array is returned with the full path of all files found. The pos [0] keeps the number of elements. Local $sCriteria, $sBuffer, $iH, $iH2, $sCS, $sCF, $sCF2, $sCP, $sFP, $sOutPut = '', $aNull[1] $sCP = StringLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCP = '' Then $sCP = @WorkingDir & '\' $sCriteria = StringTrimLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCriteria = '' Then $sCriteria = '*.*' ;To begin we seek in the starting path. $sCS = FileFindFirstFile($sCP & $sCriteria) If $sCS <> - 1 Then While 1 $sCF = FileFindNextFile($sCS) If @error Then FileClose($sCS) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop $sOutPut = $sOutPut & $sCP & $sCF & @LF WEnd EndIf $sBuffer = @CR & $sCP & '*' & @LF;The buffer is set for keeping the given path plus a *. Do $sCS = StringTrimLeft(StringLeft($sBuffer, StringInStr($sBuffer, @LF, 0, 1) - 1), 1);current search. $sCP = StringLeft($sCS, StringInStr($sCS, '\', 0, -1));Current search path. $iH = FileFindFirstFile($sCS) If $iH <> - 1 Then While 1 $sCF = FileFindNextFile($iH) If @error Then FileClose($iH) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop If StringInStr(FileGetAttrib($sCP & $sCF), 'd') Then $sBuffer = @CR & $sCP & $sCF & '\*' & @LF & $sBuffer; Every folder found is added in the begin of buffer $sFP = $sCP & $sCF & '\'; for future search $iH2 = FileFindFirstFile($sFP & $sCriteria); and checked with the criteria. If $iH2 <> - 1 Then While 1 $sCF2 = FileFindNextFile($iH2) If @error Then FileClose($iH2) ExitLoop EndIf If $sCF2 = '.' Or $sCF2 = '..' Then ContinueLoop $sOutPut = $sOutPut & $sFP & $sCF2 & @LF;Found items are put in the Output. WEnd EndIf EndIf WEnd EndIf $sBuffer = StringReplace($sBuffer, @CR & $sCS & @LF, '') Until $sBuffer = '' If $sOutPut = '' Then $aNull[0] = 0 Return $aNull Else Return StringSplit(StringTrimRight($sOutPut, 1), @LF) EndIf EndFunc ;==>_FileSearch Edited June 23, 2005 by ezzetabi
Dizzy Posted June 26, 2005 Author Posted June 26, 2005 Hi ezzetabi, i've tried your script but nothing happens. I've created a dir D:\test and copied some files in it - but no result. Did i make something wrong? I'm using autoit 3.1.1.0. Greets Dizzy
Dizzy Posted July 5, 2005 Author Posted July 5, 2005 Hi ezzetabi,i've tried your script but nothing happens. I've created a dir D:\test and copied some files in it - but no result.Did i make something wrong? I'm using autoit 3.1.1.0.Greets Dizzy<{POST_SNAPBACK}> :"> :"> :"> :"> I've to read the script a little bit better ..Thanks for the remarks ... and yes - it works.Thx!
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