GetFileList NOT pull recursive....

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
macroman
Pro Scripter
Posts: 93
Joined: Mon Jun 02, 2014 5:32 am

GetFileList NOT pull recursive....

Post by macroman » Sun Mar 13, 2016 1:06 pm

Currently using the below to pull a random photo - however, it only pull from the first parent folder, and not all the sub folders that I have... how do I make this select a random photo from any sub folders?

Code: Select all

GetFileList>%profile%\Dropbox\photos\*,file_list
Separate>file_list,;,files_array
If>files_array_count>0
  //randomize the array
  Let>k=files_array_count
  Repeat>k
    //get random number less than k
    Random>{%k%-1},random_index
    Let>random_index=random_index+1
    Let>Temp=files_array_%k%
    Let>files_array_%k%=files_array_%random_index%
    Let>files_array_%random_index%=Temp
    Let>k=k-1
  Until>k=0
Endif

User avatar
JRL
Automation Wizard
Posts: 3531
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: GetFileList NOT pull recursive....

Post by JRL » Mon Mar 14, 2016 3:36 am

I'd use DOS dir. Something like this.

Code: Select all

Let>RP_Wait=1
Let>RP_Windowmode=0
RunProgram>cmd /c dir "%profile%\Dropbox\photos\*.*" /s /b > %temp_dir%FilesList.txt
ReadFile>%temp_dir%FilesList.txt,file_list
Separate>file_list,crlf,files_array

If>files_array_count>0
  //randomize the array
  Let>k={files_array_count-1}
  Repeat>k
    //get random number less than k
    Random>{%k%-1},random_index
    Let>random_index=random_index+1
    Let>Temp=files_array_%k%
    Let>files_array_%k%=files_array_%random_index%
    Let>files_array_%random_index%=Temp
    Let>k=k-1
  Until>k=0
Endif

macroman
Pro Scripter
Posts: 93
Joined: Mon Jun 02, 2014 5:32 am

Re: GetFileList NOT pull recursive....

Post by macroman » Mon Mar 14, 2016 4:49 am

this works... but slow as heck when you have over 10k images...

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts