Select Random image from Computer Folder to upload to Social Media

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
wvfrugalchick
Newbie
Posts: 7
Joined: Sun Jul 23, 2023 4:57 pm

Select Random image from Computer Folder to upload to Social Media

Post by wvfrugalchick » Sun Jul 23, 2023 5:17 pm

I'm wanting to automate some of my daily image uploads. Each day I try to find time to upload various photos to my social media, but its time consuming. It's my way of sharing the things in my life that matter to me, and to keep my accounts active.

I can not figure out how to do this in MS. I've searched the forum and google but can not find a script or example. I could really use some assistance in figuring this out.

I'm using MS version 14.3.05, Windows 7 Ultimate. (what can I say, I like windows 7! LOL)
Last edited by wvfrugalchick on Mon Jul 24, 2023 6:46 pm, edited 2 times in total.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1354
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Select Random image from Computer Folder to upload to Social Media

Post by Dorian (MJT support) » Sun Jul 23, 2023 5:46 pm

First you can get all the files in a folder using GetFileList.

Then select one of the results randomly by using Random. The code below would find all png files in the given folder. You will see I have purposely cannibalised the examples given at GetFileList and Random to make things easier to follow. You will find in-depth descriptions of those commands.

Code: Select all

Let>GFL_SORTTYPE=3
GetFileList>C:\Users\EditMe\Pictures\Screenshots\*.png,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%

Random>file_names_count,DiceResult
Let>DiceResult=DiceResult+1
MessageModal>file_names_%DiceResult%
The posting to social media part is somewhat of a can of worms. Maybe best covered with Image Recognition.
Yes, we have a Custom Scripting Service. Message me or go here

wvfrugalchick
Newbie
Posts: 7
Joined: Sun Jul 23, 2023 4:57 pm

Re: Select Random image from Computer Folder to upload to Social Media

Post by wvfrugalchick » Sun Jul 23, 2023 6:05 pm

Dorian, Thank you for your extremely prompt reply!

I am not understanding how this "selects" one of the random images to upload. It pops up a message that tells me how many are available, and another message giving me the location of one of the random images from the folder, but I need it to select one of them, any one of them. I'm learning (slowly) and I feel silly saying I don't understand, but I don't.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1354
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Select Random image from Computer Folder to upload to Social Media

Post by Dorian (MJT support) » Sun Jul 23, 2023 6:18 pm

It's demonstrating in principle how it gets a list of files from a folder, and then chooses one of them at random.

What you do with with that once it's chosen isn't nearly as simple. The answer would be different (and likely to be quite the can of worms) for each and every social media site.
Yes, we have a Custom Scripting Service. Message me or go here

wvfrugalchick
Newbie
Posts: 7
Joined: Sun Jul 23, 2023 4:57 pm

Re: Select Random image from Computer Folder to upload to Social Media

Post by wvfrugalchick » Sun Jul 23, 2023 6:31 pm

Thank you Dorian for such a prompt reply.

I'm failing to understand how using the code examples will "select" the image.

I'm using image rec to select the "upload now" or "select image" buttons, but then after that - using the examples given - it gives me a message of how many are in that given folder and then picks a random image folder location to display as a message. I need it to actually select one out of the folder after I have clicked the upload button.

Maybe I'm not explaining myself... I've been known to do that.

For example, lets say I want to upload an image on twitter

1. First I used image rec to select the image upload button.
2. A dialog box opens for me to select an image....
3. From there I want MS to randomly pick an image to "open" from that folder " C:\Users\Public\Documents\camping\*.png "

I hope I have explained this well.
Thank you

wvfrugalchick
Newbie
Posts: 7
Joined: Sun Jul 23, 2023 4:57 pm

Re: Select Random image from Computer Folder to upload to Social Media

Post by wvfrugalchick » Sun Jul 23, 2023 6:31 pm

Ok. Thank you

wvfrugalchick
Newbie
Posts: 7
Joined: Sun Jul 23, 2023 4:57 pm

Re: Select Random image from Computer Folder to upload to Social Media

Post by wvfrugalchick » Mon Aug 21, 2023 6:55 pm

Accomplished with Python.
Thanks

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