applescript to automator workflow...

Started by motormount, January 30, 2019, 10:48:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

motormount

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!

Kermy812

#1
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

motormount

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!



Kermy812

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.

swampymarsh

#4
Quote from: motormount on January 30, 2019, 10:48:42 AMI'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:

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

.

motormount

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 !

swampymarsh

#6
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.

motormount

 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!