mr-es335 Posted September 16 Share Posted September 16 (edited) Good day, A query...if I may..."Can _FileListToArray not be deployed in the same manner as _FileListToArrayRec?" For example...from this... #include <Constants.au3> #include <File.au3> example() Func example() Local $aFiles[0] $aFiles = _FileListToArrayRec("C:\RML\SAC\VST_PlugIns", "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) For $i = 1 To $aFiles[0] FileDelete($aFiles[$i]) Next EndFunc ;==>example ...to this... #include <Constants.au3> #include <File.au3> example() Func example() Local $aFiles[0] $aFiles = _FileListToArray("C:\RML\SAC\VST_PlugIns", "*", $FLTAR_FILES) For $i = 1 To $aFiles[0] FileDelete($aFiles[$i]) Next EndFunc ;==>example The former works, whilst the latter does not work. Thanks! Edited September 16 by mr-es335 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
Andreik Posted September 16 Share Posted September 16 _FileListToArrayRec() search recursively for files in subdirectories and _FileListToArray() does not. Link to comment Share on other sites More sharing options...
mr-es335 Posted September 16 Author Share Posted September 16 ioa747, What if I do not need to perform a recursive operation? For whatever reason, I cannot get the _FileListToArray() to work!!! Any ideas? mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
water Posted September 16 Share Posted September 16 What does "does not work" exactly mean? Do you get no result, missing data, error code ...? The more information you can provide the easier it is for us to help you My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
mr-es335 Posted September 16 Author Share Posted September 16 water, This example does absolutely nothing! #include <Constants.au3> #include <File.au3> example() Func example() Local $aFiles[0] $aFiles = _FileListToArray("C:\RML\SAC\VST_PlugIns", "*", $FLTAR_FILES) For $i = 1 To $aFiles[0] FileDelete($aFiles[$i]) Next EndFunc ;==>example mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
ioa747 Posted September 16 Share Posted September 16 (edited) in the former you have the parameter $FLTAR_FULLPATH in the latter not and you don't give proper path FileDelete("C:\RML\SAC\VST_PlugIns\" & $aFiles[$i]) Edit: try and you will see #include <Constants.au3> #include <File.au3> example() Func example() Local $aFiles[0] $aFiles = _FileListToArray("C:\RML\SAC\VST_PlugIns", "*", $FLTAR_FILES) For $i = 1 To $aFiles[0] ;~ FileDelete($aFiles[$i]) ConsoleWrite($i & ") FileDelete: " & $aFiles[$i] & @CRLF) Next EndFunc ;==>example Edit: The right would be with $bReturnPath = True #include <Constants.au3> #include <File.au3> example() Func example() Local $aFiles[0] ;_FileListToArray ( $sFilePath [, $sFilter = "*" [, $iFlag = $FLTA_FILESFOLDERS [, $bReturnPath = False]]] ) $aFiles = _FileListToArray("C:\RML\SAC\VST_PlugIns", "*", $FLTAR_FILES, True) For $i = 1 To $aFiles[0] ;~ FileDelete($aFiles[$i]) ConsoleWrite($i & ") FileDelete: " & $aFiles[$i] & @CRLF) Next EndFunc ;==>example or without $bReturnPath = True which entails with $bReturnPath = False #include <Constants.au3> #include <File.au3> example() Func example() Local $aFiles[0] ;_FileListToArray ( $sFilePath [, $sFilter = "*" [, $iFlag = $FLTA_FILESFOLDERS [, $bReturnPath = False]]] ) $aFiles = _FileListToArray("C:\RML\SAC\VST_PlugIns", "*", $FLTAR_FILES) For $i = 1 To $aFiles[0] ;~ FileDelete($aFiles[$i]) ConsoleWrite($i & ") FileDelete: " & "C:\RML\SAC\VST_PlugIns\" & $aFiles[$i] & @CRLF) Next EndFunc ;==>example which could also be done with _FileListToArrayRec with changing the parameter $iRecur from $FLTAR_RECUR to FLTAR_NORECUR #include <Constants.au3> #include <File.au3> example() Func example() Local $aFiles[0] $aFiles = _FileListToArrayRec("C:\RML\SAC\VST_PlugIns", "*", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) For $i = 1 To $aFiles[0] FileDelete($aFiles[$i]) Next EndFunc ;==>example Edited September 16 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
water Posted September 16 Share Posted September 16 One of my coding rules is to check the return value or error code after each call of an AutoIt function. FileDelete returns 1 on success and 0 if there was a problem. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
ioa747 Posted September 16 Share Posted September 16 3 hours ago, mr-es335 said: ioa747, What if I do not need to perform a recursive operation? check again https://www.autoitscript.com/forum/topic/212281-_filelisttoarray-versus-_filelisttoarrayrec/#comment-1536873 I know that I know nothing 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