Search the Community
Showing results for tags 'filelisttoarrayrec'.
-
Greetings! I am in need of listing several files in a folder with its respective sizes. I found this script online, which works fine. However I'd like to insert the folder path as a variable in a dialog box. How can I replace @ScriptDir with my variable? Thanks in advance. $z = MsgBox(0,"Selected Folder",FileSelectFolder ( "Select Folder", "C:\")) ; THE VARIABLE I'D LIKE TO INCLUDE. #include <File.au3> #include <Array.au3> Local $aArray = _FileListToArrayRec(@ScriptDir, "*", $FLTAR_SORT, $FLTAR_FILES) ; ;~ _ArrayDisplay($aArray, "Sorted tree") Local $size_A[UBound($aArray)][2] For $i = 1 To UBound($aArray) -1 $size_A[$i][0] = $aArray[$i] $size_A[$i][1] = ByteSuffix(FileGetSize($aArray[$i])) Next ;~ _ArrayDisplay($size_A) _FileWriteFromArray(@ScriptDir & '\Tamanho.txt', $size_A, 1, Default, ' ') ShellExecute(@ScriptDir & '\Tamanho.txt') 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, 2) & $aArray[$Index] EndFunc ;==>ByteSuffix
-
$text = 'C:\xxx\hh\hhhh\hhh\image.JPG' $out = StringRegExp($text,'.*\\(.*)\\',1) Return the last folder hhh. I would use this expression in the cycle below. Local $aArray = _FileListToArrayRec("C:\test\app", "*app.exe", $FLTAR_FILES, 1, $FLTAR_SORT,$FLTAR_FULLPATH) $fileArray = UBound($aArray) -1 For $y = 1 To $fileArray _GUICtrlListView_AddItem($ListView, StringRegExp($aArray[$y],'.*\\(.*)\\',1), 0) Next My target is to remove everything from the path, and take only the last folder. Thanks