Dzenan03 Posted September 2, 2018 Posted September 2, 2018 (edited) I want to make a while loop, that creates variables based on a array. For thist I created the array $iDsO with the number and the name of folders in an other folder. Every folder has a different name an I want to create variables(arrays) for each folder that show me all the files in that folder. For example: I have the Folder \Folder1. In it there are the Folders \1, \2, \3. In 1, 2 and 3 there are some files(.png). The array for Folder1 is $iDsO and now I want to crate the arrays $iDsO1, $iDsO2 and $iDsO3 with the files in them can I make something like this: While $iDs > 0 ;$iDs is the number of files in Folder1>> $iDsO[0] $iDs#here should come the Foldername for example '1'# = _FileListtoArray(@ProgramFilesDir&"\Folder1\"&$iDsO[$iDs]) $iDs = $iDs - 1 Wend So that in the End I have three variabels ($iDs1, $iDs2 and $iDs3) Is this posible or if not what could I do instead ( I don´t know the number of folders in Folder1 in the begining). Edited September 2, 2018 by Dzenan03
Gianni Posted September 2, 2018 Posted September 2, 2018 without going into the merits if it is a good practice or not to create a new variable for each subfolder, here a way to go for what you have asked. In short you have to use the Assign statement. #AutoIt3Wrapper_Run_AU3Check=n #include <array.au3> #include <file.au3> $sStartFolder = @ProgramFilesDir ; get list of subfolders (not recursive) Local $aFirstLevelFolders = _FileListToArray($sStartFolder, Default, 2, True) ; fill all subfolders with it's filenames For $i = 1 To $aFirstLevelFolders[0] ; use Assign to create new variables... $aDS1 $aDS2 .... etc Assign("aDS" & $i, _FileListToArray($aFirstLevelFolders[$i], Default, 1)) ; view Array content _ArrayDisplay(Execute("$aDS" & $i)) Next Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
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