Im using a script to get all files and dirs in a specific and generates a .txt file of the result but i need to add the size of each file using the FileGetSize + ByteSuffix functions
#include <File.au3>
#include <WinAPIFiles.au3>
Global Enum Step *2 $GETFILES_NOT_DIRECTORY, $GETFILES_NOT_EXISTS ; GetFiles @error
Func G3tAllF1lesAndDirs($cpath, $txtname)
Local $sFileList = ''
GetFiles($sFileList, $cpath) ; This uses no global variable
$sFileList = StringReplace($sFileList, '|', @CRLF) ; Replace the pipe char for @CRLF
Local $handlepath = FileOpen(@DesktopDir & "\" & $txtname & ".txt",1)
; Write array to a file by passing the file name.
FileWrite($handlepath, $sFileList & @CRLF)
EndFunc ;==>Example
; By guinness on 2015/03/15. Idea by Belini and every AutoIt user who has done file searching.
Func GetFiles(ByRef $sFileList, $sFilePath)
Local Static $iCounter = 0
$sFilePath = _WinAPI_PathAddBackslash($sFilePath) ; Add backslash
If _WinAPI_PathIsDirectory($sFilePath) <> $FILE_ATTRIBUTE_DIRECTORY Then
Return SetError($GETFILES_NOT_DIRECTORY, 0, '')
EndIf
Local $hFileFind = FileFindFirstFile($sFilePath & '*')
If $hFileFind = -1 Then ; File not found
Return SetError($GETFILES_NOT_EXISTS, 0, '')
EndIf
Local $sFileName = ''
While True
$sFileName = FileFindNextFile($hFileFind)
If @error Then
ExitLoop
EndIf
If @extended Then ; Is directory.
$iCounter += 1 ; Used for recursion level
GetFiles($sFileList, $sFilePath & $sFileName)
$iCounter -= 1 ; Used for recursion level
Else
$sFileList &= $sFilePath & $sFileName & '|'
EndIf
WEnd
FileClose($hFileFind)
If $iCounter = 0 Then ; First recursion level, therefore strip pipe char
$sFileList = StringTrimRight($sFileList, StringLen('|'))
EndIf
EndFunc ;==>GetFiles
Func ByteSuffix($Bytes)
Local $Index = 0, $aArray = [' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB']
While $Bytes > 1023
$Index += 1
$Bytes /= 1024
WEnd
Return Round($Bytes) & $aArray[$Index]
EndFunc
G3tAllF1lesAndDirs(@ScriptDir, "files&folders")
Here is what i want in the .txt file by just modifying the script and using FileGetSize + ByteSuffix functions
C:\Users\G-PC\Documents\setup.exe [size of this]
C:\Users\G-PC\Documents\config.ini [size of this]
C:\Users\G-PC\Documents\image001.jpg [size of this]
C:\Users\G-PC\Documents\image002.jpg [size of this]
C:\Users\G-PC\Documents\image003.jpg [size of this]
C:\Users\G-PC\Documents\Videos\vid001.avi [size of this]
C:\Users\G-PC\Documents\Videos\vid002.avi [size of this]
C:\Users\G-PC\Documents\Videos\vid003.avi [size of this]
C:\Users\G-PC\Documents\Videos\vid004.avi [size of this]
C:\Users\G-PC\Documents\Videos\Comedy\vid001.avi [size of this]
C:\Users\G-PC\Documents\Videos\Comedy\vid002.avi [size of this]
C:\Users\G-PC\Documents\Videos\Comedy\vid003.avi [size of this]
The list is very long, i tried using using another script to overwrite the .txt file after it generates but it doesnt work/crash