Saturday, January 16, 2021

#1 2021-01-14 09:39:41 am

TheBlackBinLiner
Member
Registered: 2019-12-05
Posts: 21

Rename a folder with additional text with no path included

Hi all,

I'm struggling with a script I wish to utilise at the end of a workflow Applescript I have.
Below is the snippet of the code which goes at the end of my larger script.

At the moment the rename is including the entire path of the original folder in between the additional required name and the original folder name.

Eg - original folder name is:
707661 - JOB DETAILS

result I'm getting is:
RELEASED Dave's Mac/Users/UK/Desktop/707661 - JOB DETAILS

when what I want is:
RELEASED 707661 - JOB DETAILS

This is the snippet of code:
---------------------

    set a to theDroppedItems
    tell application "Finder" to set folder a's name to "RELEASED " & theDroppedItems

---------------------


"theDroppedItems" is the variable of the original folder, in this instance "707661 - JOB DETAILS" which was defined earlier on in my larger script.


Any ideas how I can avoid getting the path in my rename folder code?


Any assistance greatly received.

Many thanks

Dave

Offline

 

#2 2021-01-14 09:49:52 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11714
Website

Re: Rename a folder with additional text with no path included

First of all the plural form theDroppedItems is misleading because it implies a list.

You say that the script works basically so theDroppedItems is clearly an HFS path.

Ask the Finder for the name and change it

Applescript:

set a to theDroppedItems
tell application "Finder"
   set folderName to name of folder a
   set folder a's name to "RELEASED " & folderName
end tell


regards

Stefan

Offline

 

#3 Yesterday 04:15:05 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1537

Re: Rename a folder with additional text with no path included

theDroppedItems is list of aliases. To get you dropped folder alias from this alias list you need item 1 of it:

Applescript:


set a to (item 1 of theDroppedItems) -- result: 1 alias

tell application "Finder"
set folderName to name of a -- result: text
set name of a to "RELEASED " & folderName -- result: text
end tell


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#4 Yesterday 07:17:43 am

TheBlackBinLiner
Member
Registered: 2019-12-05
Posts: 21

Re: Rename a folder with additional text with no path included

Thanks both - works as expected

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)