Run action on all files at once instead of one by one?

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Is it possible to pass all files at once to an Automator workflow or application instead of on a file by file basis?

Like the name suggest "Do the following to the matched file or folder" is passing each file separately over. In some cases this is not ideal.

If the folder content matches my rules the following file actions get triggered:

  1. Convert all images
  2. Mark them yellow when they are finished.
  3. Run Automator workflow*
  4. Display a Growl notification that the job is done.

*There's this Automator workflow from Brett Terpstra that…
  1. takes a Finder selection of files
  2. optimizes the images (optional)
  3. copies them to your local blog uploads directory on your hard drive
  4. the files actullay get stored in a subfolder with actual date, c.f. "uploads/2013/02"
  5. it puts all links in your clipboard as Markdown formated inline links.
Currently I don't get a list of all files in my clipboard since Hazel passes them one by one to the script.

How to tackle this?

Option 1 would be to gather all files, put them in the clipboard and let Brett's workflow run it's magic on the copied files in the clipboard.

The script is a ruby script (https://gist.github.com/ttscoff/4514795) which runs as an Automator workflow passing input to stdin.


Option 2 would be to rebuild this:

  1. Get a filenames like "pic1.png, pic2.png"
  2. Reformat each name and add it to append it to the clipboard:
    - http://myblog.com/uploads/2013/02/pic1.png
    - http://myblog.com/uploads/2013/02/pic2.png
  3. Run John Gruber's Regex on the clipboard:

    Search:
    Code: Select all
    (?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))

    Replace:
    Code: Select all
    ![]($1)


    … to reformat those image links to the Markdown image link syntax ![](http://myblog.com/uploads/2013/02/pic2.png)
  4. Actually moving the files to the local upload folder on the hard drive with the date as folder structure base for filing. If the directory doesn't exist it has to be created.

To me option 1 looks way simpler. The question is if Hazel can pull it off with the help of AppleScript or a shell script.
pattulus
 
Posts: 13
Joined: Sun Nov 06, 2011 1:05 pm

I anticipate adding a "Get Folder Contents" automator action as the first item in the automator workflow will allow you to do what you're hoping to do.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Ok… a_freyer… that was the first thing I tried yesterday. But since it was 1 am it hasn't worked… so I started fiddling. And was just about to post the quoted text below… but you made me look at it again and now I wondered why it hasn't worked in the first place. Part of the answer might be because it's not the middle of the night.

Thanks a lot mate.

Not relevant anymore:

Okay… I'm half way there:

Code: Select all
        tell application "Finder"
   set myFolder to ((home as text) & "Dropbox:Images") as alias
   set myFiles to (every item of myFolder) as alias list
   open myFiles using "MacintoshHD:Users:YOU:Desktop:Jekyll Filer.app"
end tell


The next step is:

1. getting it to work using a variable for setting myFolder
2. get open myFiles using – "direct link to the workflow" (currently exported as app)

I'll update this post when I got it.
pattulus
 
Posts: 13
Joined: Sun Nov 06, 2011 1:05 pm


Return to Support

cron