Recent

Author Topic: applescript to automator workflow...  (Read 501 times)

0 Members and 1 Guest are viewing this topic.

Offline motormount

  • Full Member
  • ***
  • Posts: 105
applescript to automator workflow...
« on: January 30, 2019, 11:48:42 AM »
Like i read below, i'm not the only one having trouble with automator...

So I found this script on the internet, which makes folders out of filenames then moving the files inside them.

--------

for file in *; do
if [[ -f "$file" ]]; then
mkdir "${file%.*}"
mv "$file" "${file%.*}"
fi
done

--------

It works with terminal but first you must ''direct'' it to the proper folder ( writing cd and folder address inside terminal, then pasting the script )

I'd like - and i tried - using this script as a folder action with no success.
( I saved it as .scpt flie inside library/folder action scripts and then enabling folder actions to a folder, without any luck)

Then i tried with automator, as a folder action workflow, same there.

I'd really appreciate if anyone could tell me how should i do this, make a ''hot folder'' with the script above, to which when i throw a file inside, a new folder is created named after the file and then the file is moved inside the new folder.

I could also do with automator tutorials, if anyone has any or could help me find them, even in youtube - but those i saw weren't very helpful!

Thanks in advance!

Offline Kermy812

  • New Member
  • *
  • Posts: 39
Re: applescript to automator workflow...
« Reply #1 on: January 31, 2019, 12:22:57 PM »
I'm not sure if this would help or not, but I use a ABFR (A Better Finder Rename) to do pretty much the reverse of what you're doing. Basically, rename a file based on the folder name. With it, I've made a few droplets where all I do is drop my file on it, and it will rename to the same name as the folder it's in, plus add a few other things for my workflow. It's really great, you can string together multiple actions for renaming & a boat load of other stuff.

http://www.publicspace.net/ABetterFinderRename/index.html
« Last Edit: January 31, 2019, 12:42:05 PM by Kermy812 »

Offline motormount

  • Full Member
  • ***
  • Posts: 105
Re: applescript to automator workflow...
« Reply #2 on: February 06, 2019, 01:04:58 PM »
Thanks, that's not what i was really looking for.

Maybe i'm missing something but automator needs a lot of work (= develpment ) to be really useful.

Locking a pdf means you can't open it, no disable editing option available ), few -the least - resources in the web with tutorials or text on how to make your own service and import it to automator etc

I think the best option for automating tasks inside apps or with the finder is scripting, unless you work in a automated workflow like printready or prinergy.

Best - not easy, but with plenty of documentation from adobe.

Thanks again!



Offline Kermy812

  • New Member
  • *
  • Posts: 39
Re: applescript to automator workflow...
« Reply #3 on: February 07, 2019, 02:36:22 PM »
It was a thought maybe...
Have you seen this?:
https://discussions.apple.com/thread/4622032

There's some automator stuff here, but still under construction I guess:
http://www.macosxautomation.com

on your locked pdf, usually you can open & resave out of preview to unlock, or buy the PDFKey Pro app.

Offline swampymarsh

  • Full Member
  • ***
  • Posts: 155
Re: applescript to automator workflow...
« Reply #4 on: February 08, 2019, 09:04:28 AM »
Quote from: motormount link=msg=304917 date=1548866922

I'd really appreciate if anyone could tell me how should i do this, make a ''hot folder'' with the script above, to which when i throw a file inside, a new folder is created named after the file and then the file is moved inside the new folder.


Hi motormount, a “simple” change to your code was all it took:

Code: [Select]
for file in "$@"; do
if [[ -f "$file" ]]; then
mkdir "${file%.*}"
mv "$file" "${file%.*}"
fi
done


Then setup the Automator Workflow like the attached image.

I had already done all of the hard work when learning how to incorporate ExifTool command line code into the Finder, so I’m glad that was all it took for your code!

http://prepression.blogspot.com/2016/12/automator-diy-exiftool-gui-services.html

.
« Last Edit: February 08, 2019, 09:24:27 AM by swampymarsh »

Offline motormount

  • Full Member
  • ***
  • Posts: 105
Re: applescript to automator workflow...
« Reply #5 on: February 08, 2019, 03:46:32 PM »
First of all thanks a LOT.

But.

Even if i had figured out what to replace with the * representing the hot folder, i'd still be looking how to ''compose'' the workflow inside automator.

I'll check the prepression blog, but i still think automator needs  a lot of development to be useful.

Thanks Again !

Offline swampymarsh

  • Full Member
  • ***
  • Posts: 155
Re: applescript to automator workflow...
« Reply #6 on: February 08, 2019, 05:20:06 PM »
Did you see the image attached to my previous reply? This shows how to configure the Automator Workflow for your script. Yes, this is not intuitive and one may have to spend hours researching the internet to make such things work.

The link to my blogpost is just a hint at what else is possible in Automator when using non GUI based methods, whether they be command line code, scripts etc.

In the case of Folder Actions, I believe that Automator is just a more accessible front end to the existing framework that was traditionally used by AppleScript, however I could be wrong. Despite AppleScript having an “easy to write syntax” it is still beyond many users. I agree that Automator could do with more work, it is not always obvious how to correctly order or structure flows.
« Last Edit: February 08, 2019, 08:37:00 PM by swampymarsh »

Offline motormount

  • Full Member
  • ***
  • Posts: 105
Re: applescript to automator workflow...
« Reply #7 on: February 09, 2019, 01:42:18 PM »
 That's why the capitals were for, cause i saw the image, and like i wrote even if i had figure out what to write in the place of the asterix i would be still searching how to make it work inside automator.

That's why i also wrote that with scripting one might do more, there is a lot more documentation and examples all over the net.
( Talking about adobe apps and javascript )

Thanks again it works like it should and i know now how to rename a target folder!