Numbness Posted August 18 Posted August 18 I want to print all visible files and folders in a drive to a txt file. What I mean by visible is that there are 3 files and 2 folders in this drive, but there are 500 files in the folders. I only want to print 3 files and 2 folders. I don't want the contents of the folder to be printed. please help me.
Solution ioa747 Posted August 18 Solution Posted August 18 (edited) #include <File.au3> #include <Array.au3> $sFiles = _FindAll(@ScriptDir, "*", $FLTAR_FILESFOLDERS, $$FLTAR_NORECUR) ;~ _ArrayDisplay($sFiles) _FileWriteFromArray(@ScriptDir & "\Index.txt", $sFiles, 1) ShellExecute(@ScriptDir & "\Index.txt") ;---------------------------------------------------------------------------------------- Func _FindAll($dir, $sMask = "*", $iReturn = $FLTAR_FILESFOLDERS, $iRecur = $FLTAR_NORECUR) If StringRight($dir, 1) <> "\" Then $dir &= "\" $aList = _FileListToArrayRec($dir, $sMask, $iReturn, $iRecur, $FLTAR_NOSORT, $FLTAR_FULLPATH) If Not IsArray($aList) Then ConsoleWrite($dir & " There are not '" & $sMask & "' in " & $dir & @CRLF) Return SetError(1, 0, 0) Else Local $sFilePath, $sAttrib Return $aList EndIf EndFunc ;==>_FindAll ;---------------------------------------------------------------------------------------- Edit: turn it to $FLTAR_NORECUR Edited August 18 by ioa747 turn it to $FLTAR_NORECUR I know that I know nothing
Numbness Posted August 18 Author Posted August 18 19 minutes ago, ioa747 said: #include <File.au3> #include <Array.au3> $sFiles = _FindAll(@ScriptDir, "*", $FLTAR_FILESFOLDERS, $$FLTAR_NORECUR) ;~ _ArrayDisplay($sFiles) _FileWriteFromArray(@ScriptDir & "\Index.txt", $sFiles, 1) ShellExecute(@ScriptDir & "\Index.txt") ;---------------------------------------------------------------------------------------- Func _FindAll($dir, $sMask = "*", $iReturn = $FLTAR_FILESFOLDERS, $iRecur = $FLTAR_NORECUR) If StringRight($dir, 1) <> "\" Then $dir &= "\" $aList = _FileListToArrayRec($dir, $sMask, $iReturn, $iRecur, $FLTAR_NOSORT, $FLTAR_FULLPATH) If Not IsArray($aList) Then ConsoleWrite($dir & " There are not '" & $sMask & "' in " & $dir & @CRLF) Return SetError(1, 0, 0) Else Local $sFilePath, $sAttrib Return $aList EndIf EndFunc ;==>_FindAll ;---------------------------------------------------------------------------------------- Edit: turn it to $FLTAR_NORECUR I received an error message like this
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