Sorry to highjack this old post but I was hoping you could help out on this. I have already posted this question here: Applescript to rename files with creation date, then move files to a duplicated folder structure.
I've managed to tinker around with your code and a bit from elsewhere. I just have a few questions on how to amend the script.
1. Can I edit the script so I can drop a folder onto it and it runs? (like an application built in automator)
2. Is it possible to capture the original creation date of the oldest file in the folder and get it to populate the the date text box - with the creation date in the format YYYYMMDD
3.And then get the resultant duplicated folder to save in the same directory as the original folder?
Hope that all makes sense. Any help would be much appreciated.
set desktopPath to choose folder
-- Write a message into the event log.
log " --- Starting on " & ((current date) as string) & " --- "
-- debug lines
--set desktopPath to (path to desktop) as string
log "desktopPath = " & desktopPath
set unixDesktopPath to POSIX path of desktopPath
log "unixDesktopPath = " & unixDesktopPath
set quotedUnixDesktopPath to quoted form of unixDesktopPath
log "quoted form is " & quotedUnixDesktopPath
try
set fromUnix to do shell script "ls -l " & quotedUnixDesktopPath
display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
end try
tell application "Finder"
set JobDate to text returned of (display dialog "Please enter Identifier:" default answer "Date")
set catType to {"Cat 01", "Cat 02", "Cat 03"}
set JobCat to {choose from list catType}
set JobTitle to text returned of (display dialog "Please enter Identifier:" default answer "Name")
set JobName to JobDate & "_" & JobCat & "_" & JobTitle
set templateFolder to (container of (path to me) as string) & "_aa" as alias
--set folder_Contents to (get files of entire contents of folder templateFolder)
set fldName to name of templateFolder
set newName to my replace_chars(fldName, "_aa", JobName)
set destinationFolder to choose folder with prompt "Please Choose Destination Folder"
set newFolder to duplicate templateFolder to destinationFolder
set pro_folder to newFolder
set all_pro_folders to every folder of pro_folder
log all_pro_folders
repeat with parent_folder in all_pro_folders
log parent_folder
set child_folders to every folder of parent_folder
repeat with current_folder in child_folders
set grandchildItems to every item of current_folder
repeat with grandchildItem in grandchildItems
set greatgrandchildItems to every item of grandchildItem
repeat with greatgrandchildItem in greatgrandchildItems
set fold_name to the name of greatgrandchildItem
log (fold_name)
set new_name to my replace_chars(fold_name, "_aa", JobName)
set the name of greatgrandchildItem to new_name
log (new_name)
end repeat
set fold_name to the name of grandchildItem
log (fold_name)
set new_name to my replace_chars(fold_name, "_aa", JobName)
set the name of grandchildItem to new_name
log (new_name)
end repeat
set fold_name to the name of current_folder
log (fold_name)
set new_name to my replace_chars(fold_name, "_aa", JobName)
log (new_name)
set the name of current_folder to new_name
end repeat
set fold_name to the name of parent_folder
log (fold_name)
set new_name to my replace_chars(fold_name, "_aa", JobName)
log (new_name)
set the name of parent_folder to new_name
end repeat
set pro_folder's name to newName
end tell
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars