Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Can I select 1 image form a folder every time a workflow is run?

Is it possible to select one new image (never selecting the same image twice) from a folder of many images every time an automator workflow is run? If so how would I go about this?

When I was looking at automator I didn't seem to see a single action that could accomplish this. Do I have to use a variable or something? Or is this beyond the basic automator action set? If it is beyond, is it possible to write a new script that could accomplish what I need?

MacPro Quadcore 3GHz, MacBook Pro 2.5GHz, Mac OS X (10.5.4), 5GB Ram, 4GB Ram

Posted on Aug 11, 2008 7:05 AM

Reply
Question marked as Best reply

Posted on Aug 11, 2008 7:46 AM

automator user defined variables can't remember values from one run to the next. (At least I don't know how to do it). apple script on the other hand can do that. you can use apple script but I would recommend simply selecting a random image from a folder on every run. that's easier to script, can be done in automator and you don't need to worry about running out of images in the folder (this will of course happen eventually if you do what you want).

to select a random image you do something like this:

1. get selected (or specified) finder items.
get your folder with images
2. get folder content
3.run apple script action

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run {input, parameters}

return some item of input
end run</pre>
5 replies
Question marked as Best reply

Aug 11, 2008 7:46 AM in response to Erik Peterson

automator user defined variables can't remember values from one run to the next. (At least I don't know how to do it). apple script on the other hand can do that. you can use apple script but I would recommend simply selecting a random image from a folder on every run. that's easier to script, can be done in automator and you don't need to worry about running out of images in the folder (this will of course happen eventually if you do what you want).

to select a random image you do something like this:

1. get selected (or specified) finder items.
get your folder with images
2. get folder content
3.run apple script action

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run {input, parameters}

return some item of input
end run</pre>

Aug 11, 2008 9:48 AM in response to V.K.

Can you direct me to any good resources on learning applescript? I really want to get this workflow setup to just grab the next image in the folder every time it is run.

I have about 80 images I want to email 1 at a time over the next 80 weeks. So I want to create this action, add it to an iCal event and then never worry about it again 🙂

Aug 11, 2008 10:14 AM in response to Erik Peterson

learning apple script will take some time. you can start with [Apple script langauge guide from apple |http://developer.apple.com/documentation/ScriptingAutomation/AppleScript-date. html].

also try [apple script: missing manual|http://books.google.com/books?id=lG27RYw1CUAC&printsec=frontcover&dq=%22 using delimiterreturn%22&sig=ACfU3U3e sWtmGOSf_5SdJik4gl-RhBrDQ&source=gbs_similarbooks_r&cad=12].

however, for your particular issue there is no need to learn much. In fact you can easily use what i gave you to achieve what you want.

make a new folder and have the workflow take a random image from the folder with images, move it to the new folder and then attach to a new outgoing message. then make an ical event to repeat it every week and you are done.

1. get specified finder items
2. get folder contents.
3. run apple script

on run {input, parameters}

return some item of input
end run

4. move finder items.
5. make new mail message
6. send outgoing mail.

Jun 21, 2015 10:58 AM in response to V.K.

Hi,


I know this is an old thread but I want to do exactly this.


I want to be able to select a random image from a folder - move it to an other folder - then use it with a combination of Calendar & Zapier to change my profile every week.


I have never tried apple script before and am new to Automator. Can you please write a script that I can copy and paste into applescript editor?


Folder locations:

Original folder /Users/jamespbroome/Dropbox/_photos

New folder /Users/jamespbroome/Dropbox/_photos/new



Many thanks

Can I select 1 image form a folder every time a workflow is run?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.