Monday, December 18, 2017
  • Index
  •  » Automator
  •  » Changing folder names using parts of parent folder name

#1 2005-08-05 09:34:24 am

mtorrance
Member
From:: Tulsa, OK
Registered: 2005-08-05
Posts: 124

Changing folder names using parts of parent folder name

Hi All,

I'm trying to figure out a way to rename a folder using part of the parent folder that is two levels up. I'll be more specific. I'm a photographer and use an application called Capture One Pro to process our Raw files to TIFF and JPEG. When we start a new job in C1Pro we always name the job a specific way which is a Job Number and Client Name pair (i.e. 0000-00 ClientName) so C1Pro creates a folder by that name in our Work In Progress folder. Inside the folder "0000-00 ClientName" it creates three folders (Captures, Processed and Trash) The Automator action that I'm wanting to include this script in is designed to push low res files and thumbnails to our website for the client to view. When C1Pro processes the low res files and thumbnails it places them in Processed in a new folder called Web_Proofs. What I would like the script to do is prompt the user to select the job folder they want to send to the web (i.e. 0000-00 ClientName) then the script would need to copy the first 7 characters of the folder (i.e. 0000-00) the rename Web_Proofs to 0000-00 and then add Job_ to the begining the folder so Web_Proofs would be renamed Job_0000-00. Then at the end of the script pass that folder to the next Automator action. I had tried to use the script "Replace Text In Item Names" that is in the Applescript Examples folder but it required to many prompts to the user and I would like it to be more automated with the user only having to select the job folder. I have the uploading of the folder working fine so I just need to solve the renaming problem.

Thanks in advance,
Mark

Offline

 

#2 2005-08-05 10:35:56 am

Bruce Phillips
Administrator
Registered: 2004-07-16
Posts: 2649

Re: Changing folder names using parts of parent folder name

Try something like this:

Applescript:

choose folder with prompt "Choose a job folder to upload:"
set jobFolder to result

set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set clientName to every text item of (name of (info for jobFolder))
set jobNumber to first item of result
set clientName to (items 2 through -1 of clientName) as string
set AppleScript's text item delimiters to ASTID

set webFolder to ((jobFolder as string) & "Processed:Web_Proofs") as alias
tell application "Finder" to set name of result to (clientName & "_" & jobNumber)

return {webFolder}

Do your clients' names have any spaces in them? If they do, and you want to remove them before the folder is uploaded, you could add a line to [effectively] replace them.

Applescript:

-- Change this line:
set clientName to (items 2 through -1 of clientName) as string

-- To this:
set AppleScript's text item delimiters to "-" -- whatever should replace the spaces
set clientName to (items 2 through -1 of clientName) as string


Filed under: Finder

Offline

 

#3 2005-08-06 11:47:41 pm

mtorrance
Member
From:: Tulsa, OK
Registered: 2005-08-05
Posts: 124

Re: Changing folder names using parts of parent folder name

Works Great!

I made a small change to the line

Applescript:

tell application "Finder" to set name of result to (clientName & "_" & jobNumber)

to

Applescript:

tell application "Finder" to set name of result to ("Job_" & jobNumber)

Then added some scripting with transmit to use clientName to determine the correct folder on the server to upload into and some error checking in case the Web_Proofs folder didn't exist or had already been renamed.

Thanks so much for help!
Mark


Filed under: Finder

Offline

 
  • Index
  •  » Automator
  •  » Changing folder names using parts of parent folder name

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)