Re: AppleScript/Automator to create folder based on partial file name, move files

Started by davidkyoo, April 10, 2018, 03:04:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tracy

That sounds good, does this script need adjusting?
I see it says "your script goes here"
also I don't know how to save it as a Service with Automater
can you give me the steps on how to use this? very interesting.

swampymarsh

Tracy, when creating a new Automator doc, you can select "Service" or another option.

Screenshot attached.

I'd advise you to Google up and search for Automator and or AppleScript sites, there are many websites out there with great info to get beginners past the initial hurdles of getting started.

Tracy


swampymarsh

Quote from: Tracy on April 16, 2018, 03:38:57 PMHey thanks Swampy!
That should help

After creating your new blank service in Automator, copy/paste in the code and hit the "compile" spanner icon as attached.

To run, contextual/control/right click on a file and select your service command.

swampymarsh

Quote from: Tracy on April 16, 2018, 11:27:29 AMThat sounds good, does this script need adjusting?
I see it says "your script goes here"
also I don't know how to save it as a Service with Automater
can you give me the steps on how to use this? very interesting.

No adjustment required, the bit that is marked as:

(* Your script goes here *)

Is what is known as a "comment" which is ignored by the scripting engine and is used to document the script.

That line can be left, or removed.

In an earlier post I showed AppleScript code in two separate attachments, one "complex" and one "simplified".

swampymarsh

As previously mentioned, I personally find ExifTool a whole lot easier to use and it is easy enough to put it into an Automator service for easy right click access.

The AppleScript code posted by Fat Boy Tim used 43 lines of code and 1051 characters.

The equivalent ExifTool command only uses 1 line of code and 91 characters and is cross platorm (apart from the specific shell script bits that are Mac OS only).

Both methods process "instantly" and will create a new folder based on the filename of the selected file and move the file into the newly created folder. The ExifTool command has the advantage of working on multiple selected files. Of course, ExifTool can "only do so much" and it is not a scripting language, so it is a case of horses for courses.

/usr/local/bin/exiftool '-directory<${directory}/${filename;s/(^.+)(\.[^.]*$)/$1/}' -r "$@"

Tracy

This is excellent stuff, I will practice it an read about it.
I hope I get it!
wish you guys were here  :laugh: