grasshopper3 Posted June 21, 2010 Posted June 21, 2010 Can someone tell help me with this... I am trying to get this script to go through a FTP site and get me a list of files in all directories. It doesn't go any deeper than the first sub-dir. Func ScanFolders($SourceFolder, $Name) Local $FileArray,$FullFilePath, $hSearch2 MsgBox(0,'$SourceFolder',$SourceFolder & "\*.*") $FileArray = _FTP_FindFileFirst($Conn, $SourceFolder & "\*.*", $hSearch2) ;$FileArray = _FTP_FindFileFirst($Conn, $SourceFolder & "\*", $hSearch2) ;~ _ArrayDisplay($FileArray) IF $FileArray[0] = 0 or @error = -1 Then _FTP_FindFileClose($hSearch2) Else $FullFilePath = $SourceFolder & "\" & $FileArray[10] If $FileArray[1] = 16 Then ScanFolders($FullFilePath, $Name) Else EmailBody($FullFilePath, $FileArray[10], $Name, $FileArray[6]) EndIf While 1 $FileArray = _FTP_FindFileNext($hSearch2) ;~ _ArrayDisplay($FileArray) IF $FileArray[0] = 0 Then ExitLoop EndIf $FullFilePath = $SourceFolder & "\" & $FileArray[10] If $FileArray[1] = 16 Then ScanFolders($FullFilePath, $Name) Else EmailBody($FullFilePath, $FileArray[10], $Name, $FileArray[6]) EndIf WEnd EndIf _FTP_FindFileClose($hSearch2) Return
Yashied Posted June 21, 2010 Posted June 21, 2010 Only one search per session. #Include <FTPEx.au3> _FTP_Search('', 'ftp.mozilla.org') Func _FTP_Search($sRemotePath, $sHost, $sLogin = '', $sPassword = '', $iPassive = 1, $iPort = 0) Local $hFtp, $hSession, $aFind, $hFind, $Result = 1 $hFtp = _FTP_Open('MyFtp') $hSession = _FTP_Connect($hFtp, $sHost, $sLogin, $sPassword, $iPassive, $iPort) $aFind = _FTP_FindFileFirst($hSession, $sRemotePath, $hFind) While Not @error If BitAND($aFind[1], $FILE_ATTRIBUTE_DIRECTORY) Then If Not _FTP_Search($sRemotePath & '/' & $aFind[10], $sHost, $sLogin, $sPassword, $iPassive, $iPort) Then Return 0 EndIf Else ConsoleWrite($sRemotePath & '/' & $aFind[10] & @CR) EndIf $aFind = _FTP_FindFileNext($hFind) WEnd _FTP_FindFileClose($hFind) _FTP_Close($hFtp) Return $Result EndFunc ;==>_FTP_Search My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
grasshopper3 Posted June 22, 2010 Author Posted June 22, 2010 (edited) Thanks! I got it working. Only one search per session. #Include <FTPEx.au3> _FTP_Search('', 'ftp.mozilla.org') Func _FTP_Search($sRemotePath, $sHost, $sLogin = '', $sPassword = '', $iPassive = 1, $iPort = 0) Local $hFtp, $hSession, $aFind, $hFind, $Result = 1 $hFtp = _FTP_Open('MyFtp') $hSession = _FTP_Connect($hFtp, $sHost, $sLogin, $sPassword, $iPassive, $iPort) $aFind = _FTP_FindFileFirst($hSession, $sRemotePath, $hFind) While Not @error If BitAND($aFind[1], $FILE_ATTRIBUTE_DIRECTORY) Then If Not _FTP_Search($sRemotePath & '/' & $aFind[10], $sHost, $sLogin, $sPassword, $iPassive, $iPort) Then Return 0 EndIf Else ConsoleWrite($sRemotePath & '/' & $aFind[10] & @CR) EndIf $aFind = _FTP_FindFileNext($hFind) WEnd _FTP_FindFileClose($hFind) _FTP_Close($hFtp) Return $Result EndFunc ;==>_FTP_Search Edited June 22, 2010 by grasshopper3
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