Jump to content

can I combine variablenames?


Dzenan03
 Share

Recommended Posts

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 by Dzenan03
Link to comment
Share on other sites

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

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...