Tuesday, November 19, 2019
  • Index
  •  » Automator
  •  » How to use NoRandomNumber in Automator to rename image files randomly?

#1 2009-01-20 12:42:53 pm

moongold
Member
Registered: 2009-01-20
Posts: 2

How to use NoRandomNumber in Automator to rename image files randomly?

Hi Guys, I'm pretty newbie at Automator, I've made a couple of my own simple Automator Actions for movs and use third party ones fairly regularly.

I have been trying to find a way to re-number a series of sequential images within a Folder, randomly, in order to 'muddle up' the images
into a new random sequence for some animation workshops I'm running and came across the NoRandomNumber Action which looks perfect.
I would like to output the image sequence 'out of order' from the sequence it was shot in.

I've managed to 'Get the value of Variable' from NoRandom and create a variable but cannot add the resulting numeric variable to any of the fields
in Rename Finder Items which seem fixed in their intent.
I have just discovered the 'placeholder' type result which running the workflow gives but can't figure out where to use that.

I also found a post here somewhere that had the idea of using the Copy To and Get Clipboard contents for the output of NoRandom which sounded a good plan
but generally I keep coming up against my non-programming lack of understanding as regards variables as well as the general sequence of actions and am back at square one.

What is the best way to use the output of NoRandomNumbers?
Is using variables the way to go? If not what?
Is there any other way to rename files other than using ReName Finder Items?

I'm now at that hell point reserved for people with just enough knowledge to get somewhere but not enough to finish.
Any help gratefully accepted, many thanks.


Filed under: random,automator

Offline

 

#2 2009-01-20 03:02:38 pm

Craig Smith
Administrator
From:: Tacoma, WA
Registered: 2005-05-16
Posts: 1027
Website

Re: How to use NoRandomNumber in Automator to rename image files randomly?

This sort of thing is a bit over Automator's head.  Automator is designed to work on a single item through a workflow, whether that item is a file or a group of files does not matter; it will not go through a group of files and treat each one individually unless you set up a Run AppleScript or Do Shell Script action.

For what you want to do, a stand alone AppleScript may work, or it can be modified to fit inside of a Run AppleScript action as well.  Try this and see if it close to what you want:

Applescript:

set image_folder to choose folder
set ct to 1
tell application "Finder"
   set count_er to count (get every file in image_folder)
   set new_nums to my GetRandomNumbers(count_er)
   repeat with each_file in (get every file in image_folder)
       set name of each_file to ("NewName" & (item ct of new_nums as text) & ".jpg")--This assumes that all the files are jpg, you can change this to the proper file extension.
       set ct to ct + 1
   end repeat
end tell

to GetRandomNumbers(x)
   set random_set to {}
   repeat until ((random_set's length) = x)
       set new_rand to random number from 1 to (x * 10)
       if random_set does not contain new_rand then set end of random_set to new_rand
   end repeat
   return random_set
end GetRandomNumbers

Good luck,

Last edited by Craig Smith (2009-01-20 03:04:26 pm)


Craig Smith


Filed under: Finder

Offline

 

#3 2009-01-20 06:50:29 pm

moongold
Member
Registered: 2009-01-20
Posts: 2

Re: How to use NoRandomNumber in Automator to rename image files randomly?

Craig, that's fantastic. I'm not sure what you/I've done but I opened the scriptlet in Text Wrangler
and ran it and Hey Presto! :-) 
Very happy Automator noodler here, can't thank you enough.

I learned lots trying to get Automator to do what I wanted so it wasn't time wasted at all ...
And it's good to know the Automator limitation you mention.

Do you mind if I share this Script with students and a.n.other if the moment arises?

Big thanks, Gareth

Offline

 

#4 2009-01-20 07:37:18 pm

Craig Smith
Administrator
From:: Tacoma, WA
Registered: 2005-05-16
Posts: 1027
Website

Re: How to use NoRandomNumber in Automator to rename image files randomly?

Glad to hear it worked, Gareth.  Feel free to share it however you like, but please include my name and email address for anyone that needs help with it.  (You can get the email by clicking the highlighted E-mail link next to my posts.)


Craig Smith

Offline

 

#5 2019-10-23 07:00:46 am

Stadler
Member
Registered: 2008-07-09
Posts: 11

Re: How to use NoRandomNumber in Automator to rename image files randomly?

This is amazing!  I was able to use this as well!

Offline

 
  • Index
  •  » Automator
  •  » How to use NoRandomNumber in Automator to rename image files randomly?

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)