Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.