TripScott Posted July 26, 2010 Share Posted July 26, 2010 (edited) When I run this code in SciTE it works perfectly. However, once it is compiled it gives an @error code 5 -- file not found. It isn't picking up the subfolder that the zip file is in. Anyone know why this is happening and how to fix it? I am running AutoIt 3.3.6.1. #include <File.au3> #include <Zip.au3> #include <Array.au3> Dim $myFolder $sRoot = 'C:\data\pimvault' $sFile = '*.zip' Func _FindFile($sRoot, $sFile) If FileExists($sRoot & '\' & $sFile) Then Return $sRoot EndIf Local $Result = '', $FileList = _FileListToArray($sRoot, '*', 2) If Not @error Then For $i = 1 To $FileList[0] $Result = _FindFile($sRoot & '\' & $FileList[$i], $sFile) $myFolder = $FileList[$i] If Not @error Then ExitLoop EndIf Next EndIf Return SetError(($Result = ''), 0, $Result) EndFunc ;==>_FindFile $find = _FindFile($sRoot, $sFile) $sZipFile = "C:\data\pimvault\" & $myFolder & "\" & $myFolder & ".zip" $sFileName = "C:\data\ProductView\" & $myFolder & "REF.edz" $sZip = _Zip_AddItem($sZipFile, $sFileName, "", 1) Edited July 26, 2010 by TripScott Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 26, 2010 Moderators Share Posted July 26, 2010 TripScott,You declare $myFolder but leave it empty. You then use that empty variable to declare both $sZipFile and $sFileName - which you then pass to the UDF. Why are you surprised that the UDF cannot then find the file, given that both parameters are likely to be complete nonsense? Did you actually check what you were passing as parameters - always a good idea if you get an error from a UDF! M23Hint: You need to look again at the name of the variable you use to capture the return value of the _FindFile function.P.S. And do not forget to error check what that ugly recursive function gives you either. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
TripScott Posted July 26, 2010 Author Share Posted July 26, 2010 I am trying to get the name of the subfolder. This function is the only thing I can find that does it, however, not when compiled. What I really want is to get the name of the subfolder as a variable so I can use it in the zip function. Is there an easier way? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 26, 2010 Moderators Share Posted July 26, 2010 TripScott,Oops! Ignore everything I posted above, I was having a "senior moment" - $myFolder is of course Global and so is set by the function. Top Tip: Much better coding practice to use Global/Local instead of Dim to make the scope explicit. However, that search function of yours is not optimal - it seems to set $myFolder to the last searched folder in the "not found" case. That would explain why you get the "file not found" error. There are plenty of much better recursive file search scripts out there (most of which do not use recursion either!) - if I were you I would go and find a better one.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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