Thanks and duly noted. Here’s the full script—with your additions—to help with the context. I’m hoping won’t be a horrible mess to swim through. Don’t mind my notes elsewhere in the script, I’m making tweaks elsewhere to it.
--SETUP: version 2.00a
--set delimiters for filename sequence
set text item delimiters to "."
--set default loop count
set seqCount to 1
--get job code, format ABCDEXX###
display dialog "ENTER JOB CODE:" default answer "JobCode"
set projCode to text returned of result
--designate project folder
set projectFolder to choose folder with prompt "SELECT PROJECT FOLDER for " & projCode
--choose zip/nozip here, else jump to startPrep
display dialog "NEED TO ZIP/RENAME ZIPPED FONTS?" buttons {"Zip Fonts", "Rename Zipped", "Skip"} default button 1 with icon caution
set w to button returned of result
if w is "Zip Fonts" then
--zip fonts folder
set typePreviewNeed to "yes"
zipFonts(projectFolder, projCode, seqCount, typePreviewNeed)
else if w is "Rename Zipped" then
--rename zipped font file
set typePreviewNeed to "yes"
renameZip(projectFolder, projCode, seqCount, typePreviewNeed)
else if w is "Skip" then
--check for PDF
set typePreviewNeed to "no"
checkPDF(projCode, projectFolder, seqCount, typePreviewNeed)
end if
--ZIP FONT FOLDER
on zipFonts(projectFolder, projCode, seqCount, typePreviewNeed)
tell application "Finder"
--set zip filename append pre suffix
set zipSuffix to "_TYPEFACES"
--pick font folder
set inputFolder to choose folder default location projectFolder with prompt "SELECT FONT FOLDER for " & projCode
--path to _Fonts_ReadMe.txt
set fontsReadMe to (path to me as string) & "Contents:Resources:_Fonts_ReadMe.txt"
--duplicate file to font folder
set dupeRM to duplicate of fontsReadMe to inputFolder
--execute shell command to zip
set qpp to quoted form of POSIX path of inputFolder
do shell script "cd $(dirname " & qpp & ")
zip -r \"$(basename " & projCode & "_TYPEFACES" & ").zip\" \"$(basename " & qpp & ")\""
--delete the original font folder
delete folder inputFolder
--notify completion
display notification "FONTS ZIPPED"
end tell
--go to next step
checkPDF(projCode, projectFolder, seqCount, typePreviewNeed)
end zipFonts
--RENAME ZIPPED FONT FOLDER
on renameZip(projectFolder, projCode, seqCount, typePreviewNeed)
tell application "Finder"
set mainZIP to (choose file default location projectFolder with prompt "SELECT ZIPPED FONTS for " & projCode)
--get the filename to save the extension
set mainZIPCount to text items of (get name of mainZIP)
--pull original filename extension
if number of mainZIPCount is 1 then
set mainExt to ""
else
set mainExt to "." & item -1 of mainZIPCount
end if
--rename file with extension (Finder removes extensions by default when renaming)
set the name of mainZIP to projCode & "_TYPEFACES" & mainExt as string
--copy fontsReadMe to projectFolder
set fontsReadMe to (path to me as string) & "Contents:Resources:_Fonts_ReadMe.txt"
set dupeRM to duplicate of fontsReadMe to projectFolder
end tell
--go to next step
checkPDF(projCode, projectFolder, seqCount, typePreviewNeed)
end renameZip
on checkPDF(projCode, projectFolder, seqCount, typePreviewNeed)
display dialog "PROJECT CONTAINS PDF OF MECHANICAL?" buttons {"Yes", "No", "Cancel"} default button 1 with icon caution
set v to button returned of result
if v is "Yes" then
--go to PDF process
prepPDF(projCode, projectFolder, seqCount, typePreviewNeed)
else if v is "No" then
--skip step and start prep
display notification "SKIPPING STEP PLEASE CREATE PDF MANUALLY"
else if v is "Cancel" then
display notification "PROCESS CANCELLED"
cancel
end if
startPrep(projCode, projectFolder, seqCount, typePreviewNeed)
end checkPDF
on prepPDF(projCode, projectFolder, seqCount, typePreviewNeed)
tell application "Finder"
--DESIGNATE MAIN PDF
set mainPDF to (choose file default location projectFolder with prompt "SELECT MAIN PDF FILE for " & projCode)
--get the filename to save the extension
set mainFNCount to text items of (get name of mainPDF)
--pull original filename extension
if number of mainFNCount is 1 then
set mainExt to ""
else
set mainExt to "." & item -1 of mainFNCount
end if
--rename file with extension (Finder removes extensions by default when renaming)
set the name of mainPDF to projCode & "_PDF01" & mainExt as string
end tell
--continue to next step
startPrep(projCode, projectFolder, seqCount, typePreviewNeed)
end prepPDF
on startPrep(projCode, projectFolder, seqCount, typePreviewNeed)
--try omitting the tells?
tell application "Finder"
--CREATE NEW PROJECT FOLDERS AND SORT FILES
make new folder at projectFolder with properties {name:"HIRES"}
--set path to move to HIRES folder
set hiFiles to (projectFolder as string) & "HIRES"
--designate files to move into HIRES
set targetFiles to get every item of (entire contents of projectFolder) whose kind ≠ "Folder"
--move files into HIRES
move targetFiles to hiFiles
--remove extraneous folders
delete (every folder of projectFolder whose name is not "HIRES")
--create preview folder
make new folder at projectFolder with properties {name:"PREVIEWS"}
--copy font typeface preview file to PREVIEW folder
if typePreviewNeed = "yes" then
set typePreview to (path to me as string) & "Contents:Resources:_TYPEFACES.jpg"
set dupeTP to (duplicate of typePreview to folder of folder projectFolder with name) = "PREVIEWS" --rework line of code, not working
set name of dupeTP to newName
set newName of dupeRM to projCode & "_TYPEFACES.jpg"
end if
--DESIGNATE MAIN MECHANICAL
set mainMech to (choose file default location projectFolder with prompt "SELECT MAIN MECHANICAL FILE for " & projCode)
--get the filename to save the extension
set mainFNCount to text items of (get name of mainMech)
--pull original filename extension
if number of mainFNCount is 1 then
set mainExt to ""
else
set mainExt to "." & item -1 of mainFNCount
end if
--rename file with extension (Finder removes extensions by default when renaming)
set the name of mainMech to projCode & mainExt as string
end tell
--start next step
initSeq(projCode, projectFolder, seqCount)
end startPrep
--RENAME/SEQUENCE SUPPORT FILES
--check current initSeq count
--for later: put in code to bring app to the front during the seqArt, seqBit, etc loops?
on initSeq(projCode, projectFolder, seqCount)
--default sequence order
if seqCount = 1 then
seqART(projCode, projectFolder, seqCount)
else if seqCount = 2 then
seqBIT(projCode, projectFolder, seqCount)
else if seqCount = 3 then
seqIL(projCode, projectFolder, seqCount)
else if seqCount = 4 then
seqLYRD(projCode, projectFolder, seqCount)
else if seqCount > 4 then
--extract project code for folder prepend
set prePend to text -5 thru -1 of projCode
--prepend project code to projectFolder name
tell application "System Events" to set name of projectFolder to (prePend & " - " & (get name of projectFolder))
--reset count for next project
set seqCount to 1
display notification "PLEASE CREATE PREVIEWS AND RELINK TO MECHANICAL." with title "PROJECT " & projCode & " PREP COMPLETED." sound name "Purr"
delay 2
quit
end if
end initSeq
--sequence through different support files
--sequence _ART
on seqART(projCode, projectFolder, seqCount)
set fileSuffix to "_ART"
tell application "System Events" to set frontmost of process "SuperPrepScrip_v2_00" to true --comment out if this doesn't keep the dialog box up front; may not work in script test format
display dialog "Rename/Sequence _ART?" buttons {"Yes", "Skip", "Cancel"} default button 1 with icon caution
set x to button returned of result
if x is "Yes" then
seqFILES(fileSuffix, projectFolder, projCode, seqCount)
else if x is "Skip" then
set seqCount to seqCount + 1
seqBIT(projCode, projectFolder, seqCount)
else if x is "Cancel" then
delay 2
display notification "PROCESS CANCELLED" sound name "Basso"
cancel
end if
end seqART
--sequence _BIT
on seqBIT(projCode, projectFolder, seqCount)
set fileSuffix to "_BIT"
tell application "System Events" to set frontmost of process "SuperPrepScrip_v2_00" to true --comment out if this doesn't keep the dialog box up front; may not work in script test format
display dialog "Rename/Sequence _BIT?" buttons {"Yes", "Skip", "Cancel"} default button 1 with icon caution
set x to button returned of result
if x is "Yes" then
seqFILES(fileSuffix, projectFolder, projCode, seqCount)
else if x is "Skip" then
set seqCount to seqCount + 1
seqIL(projCode, projectFolder, seqCount)
else if x is "Cancel" then
delay 2
display notification "PROCESS CANCELLED" sound name "Basso"
cancel
end if
end seqBIT
--sequence _IL
on seqIL(projCode, projectFolder, seqCount)
set fileSuffix to "_IL"
tell application "System Events" to set frontmost of process "SuperPrepScrip_v2_00" to true --comment out if this doesn't keep the dialog box up front; may not work in script test format
display dialog "Rename/Sequence _IL?" buttons {"Yes", "Skip", "Cancel"} default button 1 with icon caution
set x to button returned of result
if x is "Yes" then
seqFILES(fileSuffix, projectFolder, projCode, seqCount)
else if x is "Skip" then
set seqCount to seqCount + 1
seqLYRD(projCode, projectFolder, seqCount)
else if x is "Cancel" then
delay 2
display notification "PROCESS CANCELLED" sound name "Basso"
cancel
end if
end seqIL
--sequence _LYRD
on seqLYRD(projCode, projectFolder, seqCount)
set fileSuffix to "_LYRD"
tell application "System Events" to set frontmost of process "SuperPrepScrip_v2_00" to true --comment out if this doesn't keep the dialog box up front; may not work in script test format
display dialog "Rename/Sequence _LYRD?" buttons {"Yes", "Skip", "Cancel"} default button 1 with icon caution
set x to button returned of result
if x is "Yes" then
seqFILES(fileSuffix, projectFolder, projCode, seqCount)
else if x is "Skip" then
set seqCount to seqCount + 1
initSeq(projCode, projectFolder, seqCount)
else if x is "Cancel" then
delay 2
display notification "PROCESS CANCELLED" sound name "Basso"
cancel
end if
end seqLYRD
--rename support files in sequence
on seqFILES(fileSuffix, projectFolder, projCode, seqCount)
--RENAME ALL SUPPORT FILES IN SEQUENCE
--tell application "Finder"
--pick files
set all_files to (choose file with prompt "SELECT " & fileSuffix & " FILES:" with multiple selections allowed)
--get _BEFORE_AND_AFTER list, initially just the _BEFORE items
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to linefeed
set _BEFORE_AND_AFTER to paragraphs of (all_files as text) -- List of the original paths.
-- TIDs not reset yet as they're changed a lot during the repeat.
--start looping through all selected files. 'index' is our counter that we initially set to 1 and then count up with every file.
--the 'index' number is required for the sequential renaming of files
repeat with |index| from 1 to (count _BEFORE_AND_AFTER)
--using our index, we select the appropriate path from our list
set old_path to item |index| of _BEFORE_AND_AFTER
-- Get both the path to the file's container and the name of the file, omitting any trailing ":" if the "file"'s a bundle.
if (old_path ends with ":") then set old_path to text 1 thru -2 of old_path
set AppleScript's text item delimiters to ":"
set container_path to text 1 thru text item -2 of old_path
set old_name to text item -1 of old_path
--if the index number is lower than 10, we will add a preceding "0" for a proper filename sorting later
set file_index to text -2 thru -1 of ((100 + |index|) as text)
--check if the current file from our list (based on index-number) has any file-extension
if (old_name contains ".") then
set AppleScript's text item delimiters to "."
set file_extension to "." & text item -1 of old_name
else
set file_extension to ""
end if
--rename file, add the sequential number from 'index' and add the file-extension to it
set new_name to projCode & fileSuffix & file_index & file_extension
tell application "Finder" to set the name of item old_path to new_name
--update the entry in the _BEFORE_AND_AFTER list
set new_path to container_path & ":" & new_name
set item |index| of _BEFORE_AND_AFTER to old_path & " => " & new_path
end repeat
--coerce the _BEFORE_AND_AFTER list to text and reset the delimiters
set AppleScript's text item delimiters to linefeed
set _BEFORE_AND_AFTER to _BEFORE_AND_AFTER as text
set AppleScript's text item delimiters to astid
--Open the file for write access, creating it if it doesn't exist.
set fileAccess to (open for access file ((projectFolder as text) & fileSuffix & "_BEFORE_AND_AFTER") with write permission)
try -- Ensure that any errors don't stop the script before it's closed the access channel.
set eof fileAccess to 0 -- Empty the file as a formality.
write _BEFORE_AND_AFTER as «class utf8» to fileAccess -- Write the text to the file as UTF-8.
end try
close access fileAccess
display notification "File Rename Complete " & |index| & " files with '" & projCode & "_" & fileSuffix & "' for you."
--end tell
--add in increment to seqCount and restart sequence
set seqCount to seqCount + 1
initSeq(projCode, projectFolder, seqCount)
end seqFILES