hi all,
i found this script which gets me close:
http://macscripter.net/viewtopic.php?id=36664
my goal is a bit different. Like others looking for this script, I have a ton of finder folders with the ‘correct’ names. And, inside of each folder I have a number of files (usually 3); each of a different file type.
I’d like to get the name of the enclosing folder, and rename each of its enclosed files to exactly the same name as the folder, the only difference being their file extension.
so, regardless of the original file names inside each folder, i’d end up with items named like their parent folder:
01-atlas layout
01-atlas layout.idd
01-atlas layout.psd
01-atlas layout.jpg
02-APS design
02-APS design.idd
02-APS design.psd
02-APS design.jpg
so, here’s what little modification i’ve done so far, with the issues i’m having below it:
tell application "Finder"
set a to every folder of entire contents of (choose folder)
repeat with aa in a
set Base_Name to my MakeBase(aa as string)
set count_er to 1
set all_files to (every file in aa)
repeat with ff in all_files
set ff's name to (Base_Name & "." & (ff's name extension))
set count_er to count_er + 1
end repeat
end repeat
end tell
to MakeBase(txt)
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set new_Name_Raw to every text item of txt
set AppleScript's text item delimiters to "_"
set final_Name to every text item of new_Name_Raw as text
set AppleScript's text item delimiters to astid
return final_Name
end MakeBase
you’ll see that i’ve removed out the sequential counter. But, in doing so, I’ve also messed up the script and I can’t tell why. Now, when I run the script, the first item in each folder is completely missing its file extension; leading me to believe i’ve somehow messed up the counter. but, i can’t find the issue.
and, my 2nd issue is that i can’t seem to modify the path command to only take the final folder name and not the entire path of the folder to the file name.
any help is appreciated.
Model: iMac
AppleScript: 2.2.4
Browser: Safari 537.36
Operating System: Mac OS X (10.7)