0
votes

Hi all, total newbie to any kind of programming, but I've written an Automator workflow to do a repetitive task I do daily. Basically I'm prepping artwork files and folders to send out to printers. The steps are as follows:

Set Value of Variable (variable is ArtworkFolder)

where I drop the artwork folder containing the illustrator file and PDF

Get Specified Finder Items

locates a file on a RAID server

Copy Finder Items (to ArtworkFolder)

copies said file into the folder

Ask for Confirmation -

prompts user to select an updated PDF

Ask for Finder Items -

opens the folder where the new PDF sits

Copy Finder Items (to ArtworkFolder)-

copies PDF file into the folder (overwriting older files)

Ask for Confirmation

prompts user to select print guidelines

Ask for Finder Items

opens the folder where the print guidelines sit

Copy Finder Items (to variable ArtworkFolder) -

copies print guidelines into the folder

THIS IS WHERE I THINK IT MAY BE GOING AWRY

Get Value of Variable (ArtworkFolder)

this is supposed to get the name of the original folder

Get Specified Finder Items

and all its contents

Create Archive

Then Zip the whole lot together

But it zips it with the name Archive.zip which I don't want so...

Rename Finder Items: Replace Text

which is set to find "Archive" in basename only ignoring Case. then replace that with the variable ArtworkFolder

but it renames the folder with the entire path

I've tried to strip out the path by adding…

Rename Finder Items: Replace Text

which is set to find everything in the path basename only up to the unique folder name and replace with nothing (eg I left the Replace box blank)

But then it duplicates the folder name like this:

00000- Test Artwork Folder/00000- Test Artwork Folder.zip

All I want is to original folder name (00000- Test Artwork Folder) as the zip file name.

Any tips would be greatly received!

1

1 Answers

0
votes

For whatever reason, Automator doesn't have an included action to get file names, so you will need to use a third-party action or do it yourself. A Run AppleScript action can be used, but either way, note that you will need to save the workflow items and use the Ignore Input option as appropriate around getting the names, so you don't get them mixed in with the file items (also note that the workflow and action items are a list).

To get the name of a single item, something like the following can be inserted into your workflow, where the variable for the name can be used in the rename action:

Set Value of Variable { Variable: Original Input } -- stash current items

Run AppleScript: -- get the name

on run {input, parameters}
    set {theContainer, theName, theExtension} to getNamePieces from (first item of input)
    return theName
end run

to getNamePieces from somePath
    tell application "System Events" to tell disk item (somePath as text)
        set _container to path of container
        set {_name, _extension} to {name, name extension}
    end tell
    if _extension is not "" then
        set _name to text 1 thru -((count _extension) + 2) of _name -- just the name part
        set _extension to "." & _extension
    end if
    return {_container, _name, _extension}
end getNamePieces

Set Value of Variable { Variable: Item Name }

Get Value of Variable { Variable: Original Input } (Ignore Input) -- continue workflow