Applescript to copy a folder several steps back in the hierarchy

Hi experts,

I have an Automator workflow which runs through its processes once a “ColaArtwork” folder is manually dropped on it to send files out to printers.

What I want to do is before the Automator process commences I want the dropped folder to contain another folder (“ColaTechFiles") which has guidelines and tech files specific to the “ColaArtwork” folder contents.
This action/script would be an additional step in Automator prior to the main processes beginning.

Unfortunately this specific tech files folder name changes depending what type of “Artwork” folder it is. For example “ColaArtwork” has “ColaTechFiles”, “SoupArtwork” would have “SoupTechFiles” and so on.
So it’s not a generic tech files folder that can be hosted somewhere else and have the script point to it every time it’s actioned.

The folder hierarchy is a little deep so I need the script to “look back” at it’s own “COLA BRAND" folder and grab this other specific tech files folder, copy it over, before carrying on, e.g:

“ColaArtwork” folder path…
/Volumes/MacRAID/LIVE ARTWORK/•• IRELAND REGION SPECIFIC/COLA BRAND/1• IN PROGRESS/Completed - on approval/ColaFileDetails/ColaArtwork

So when this folder is dragged and dropped on to the Automator workflow I want it to look back at its own “BRAND” folder it came from (be it “COLA BRAND”, “SOUP BRAND” etc) and grab the specific “TechFiles” folder for that artwork, in this case “ColaTechFiles” and copy into the “ColaArtwork” folder.

“****TechFiles” folder path…
/Volumes/MacRAID/LIVE ARTWORK/•• IRELAND REGION SPECIFIC/COLA BRAND/ColaTechFiles

Currently I do this manually - the Automator prompts me and I manually locate the TechFiles folder and copy it across.

I’m guessing I’d need to set the “****BRAND” folder as a variable for the script to pick it up - however as that folder never physically touches the script (it’s a subfolder 4 layers back) I’m stumped as to how to do it or even if it’s possible.

Any help greatly received

You can use “container”, and concatenate as many times as you want …

set myPath to alias "MacBook HD:Users:ldicroce:Desktop:C:B:A:"
tell application "Finder" to set myFolder to container of container of myPath
myFolder -- gives you the "alias"
myFolder as text -- gives you the  path "MacBook HD:Users:ldicroce:Desktop:C:"

My suggestion.

set artworkPath to "/Volumes/MacRAID/LIVE ARTWORK/•• IRELAND REGION SPECIFIC/COLA BRAND/1• IN PROGRESS/Completed - on approval/ColaFileDetails/ColaArtwork"

set TID to text item delimiters
set text item delimiters to "/"

set techFilePath to text 1 thru text item -5 of artworkPath
set productName to text 1 thru -8 of text item -1 of artworkPath
set techFilePath to techFilePath & "/" & productName & "TechFiles"

set text item delimiters to TID

techFilePath --> "/Volumes/MacRAID/LIVE ARTWORK/•• IRELAND REGION SPECIFIC/COLA BRAND/ColaTechFiles"

POSIX paths often end with a forward slash, in which case the following should be used.

set artworkPath to "/Volumes/MacRAID/LIVE ARTWORK/•• IRELAND REGION SPECIFIC/COLA BRAND/1• IN PROGRESS/Completed - on approval/ColaFileDetails/ColaArtwork/"

set TID to text item delimiters
set text item delimiters to "/"

set techFilePath to text 1 thru text item -6 of artworkPath
set productName to text 1 thru -8 of text item -2 of artworkPath
set techFilePath to techFilePath & "/" & productName & "TechFiles/"

set text item delimiters to TID

techFilePath --> "/Volumes/MacRAID/LIVE ARTWORK/•• IRELAND REGION SPECIFIC/COLA BRAND/ColaTechFiles"