Automator get first 3 letters of parent folder

applescriptautomationautomatorbashfinder

How do i get the first 3 letters of the parent folder im creating a folder in with automator

im designing a Automator service to create a project folder in the folder of a client and I want to append the first three letters of that clients folder name to the next folder.

Client folder: Coca-Cola > new project_COC
how do i append the first three letters of Coca-Cola (COC) in capital to the new folder.

Best Answer

As an Example on how to get the 3 chars.:

You can get the details from some unix code that gets the folder name from parents path and gets the first 3 letters and transforms it into upper case.

Passes it on to the storage var. to use in the Make folder or what ever you use.

enter image description here

for f in "$@"
do
    sufx=`basename "$f" |cut -c-3 | tr "[a-z]" "[A-Z]"`

echo _"$sufx"
done