use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set theFile to choose file
tell application "System Events"
set theFileExtension to name extension of theFile
set name of theFile to (name of container of container of theFile) & "." & theFileExtension
end tell
Awesome! That worked. I added a part to append the word “_APPEND”.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set theFile to choose file
tell application "System Events"
set theFileExtension to name extension of theFile
set name of theFile to (name of container of container of theFile) & "_APPEND" & "." & theFileExtension
end tell
But, I can’t get Automator to send the selected file to the script.
In the window that pops up, highlight Quick Action and then hit Choose.
Now in the Library section on the left, click on Utilities and then find Set Value of Variable. Drag it to the main window on the right.
In the Variable dropdown, choose New variable… and call it original_Files
In the Workflow receives current choose files or folders
Set the in dropdown to Finder.app
Still in the Utilities section of the Library on the left, find Run AppleScript. Drag it to the main window under our last step.
Opens shell-script:
[b]on run {input, parameters}
(* Your script goes here *)
return input
end run[/b]
Replace (* Your script goes here *) with our script lines to get this:
on run {input, parameters}
set theFile to item 1 of input
tell application "System Events"
set theFileExtension to name extension of theFile
set name of theFile to (name of container of container of theFile) & "_APPEND" & "." & theFileExtension
end tell
return input
end run
Go to File > Save and give your new quick action a name. I’ll call mine append_GrandFolderName.
You have just created a Service (quick action). This means that if you right-click anybody file in Finder, you can see service append_GrandFolderName at bottom of pop up menu and use it by clicking.
Thanks for the update, KniazidisR. I followed your instructions a few times, but I keep getting an error, I included screenshots below.
Is the variable missing from the script? If the Variable is “original_name”, should the script include “set theFile to original_name”? Or is that, like, not a thing.