Jump to content
Macro Express Forums

Newbie Question - Repeat With Folder


roostermt
 Share

Recommended Posts

I'm trying to create something very simple but must be missing something.

 

I simply want to randomly select a random template.html file in 8 directoies.

 

I can't seem to set this up using the Repeat with Folder.

 

I put a text box so I could see what it's displayer but it only shows 1 in the variable (the last directory).

 

Could someone give me a hand.

 

If I could get the random file name to the variable I could do the rest.

 

Rooster

Link to comment
Share on other sites

I'm sorry but I don't understand what it is you are trying to do. Could you explain in a bit more detail? You say you want to select a random file, does that mean that you want to randomly select a file from many or that you want to select a file that appears randomly?

 

Which ever the case it sounds like you were looking to see a list of files instead of just one. If this is the case if you repeat with folder it will repeat once for each file name, each time writing that file name to the variable. So all you will see in the variable is the last file. So if you want to see all the files create a second variable as an accumulator. Inside the repeat loop append to the variable with the repeat variable. Add a CRLF at the end each time. Now you can display a list. To see how to generate teh CRLF click here.

 

If you want to be able to choose one from this list you can write that accumulator to the multiple choice dialog box. Even though it’s only entered as one variable, %T2% perhaps, it will appear as several lines when you run the macro. Then if you choose the third one it will only take that line on to whatever else you want to do.

 

I doubt this helps, I was just talking a stab at it. I you give us more detail we can help you better.

Link to comment
Share on other sites

Yep that helps allot.

 

I don't want to pick a variable using a box. I just want a random folder picked that I'm going to upload).

 

I'm new so not sure how to use the repeat function. But I will look into that.

 

I simply want a list of folders listed under a main directory. Then choose one by random.

 

I just can't figure out how to add each folder to the variable.

 

I actually have it createing a text file then parse the file. More steps but it works.

 

Thanks

 

Rooster

Link to comment
Share on other sites

I see what you are trying to do. I haven’t thought about this too much but I think this is how I would approach it. First I would run a repeat with parent folder. Let’s call the parent folder T1. In the repeat I would use an integer variable that would be incremented each iteration in order to count the number of folders. Let’s call that N1. Now let’s generate a random number less than N1. Do a Variable Set Integer and select the Set a Random Value. But here’s the trick. In the field for the maximum value set the value to %N1%. For the Choose Variable Name select N1. This simply overwrites N1 with the new random generated integer since we won’t need the number of folders any more. Then I would do another repeat with T1 each time setting T2 to the Replace With Name. I would then have it create N2 like we did N1 in the first repeat as a counter. But I would put an “IF” in there as well. If N1 = N2 then do a Repeat Exit which will cause it to exit the loop when the random value is reached. Now T2 is a randomly generated folder path! Quick and dirty. If you can’t get this to work or if I did a poor job of explaining please let me know and I’ll actually create one for you as an example.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...