Perfect, works like a charm. I had to rename the token, for some reason applescript didn't like NewFileName, it wanted NewFilename.
Thanks for the help, you really helped me out.
Shawn
Moderator: Mr_Noodle
tell application "Finder" to set shortName to name of (theFile as alias)
set theDialogText to "Type the new name of the Screen Shot: " & shortName
set theButtonIfPressedTheRuleWillContinue to "Rename Screen Shot"
set theButtonIfPressedRuleAborts to "Skip File"
set theDialogTitle to "Advanced Hazel Renaming"
tell application "System Events"
activate
set theResult to (display dialog theDialogText with title theDialogTitle default answer "" buttons {theButtonIfPressedTheRuleWillContinue, theButtonIfPressedRuleAborts} default button 1 giving up after 60)
end tell
if (button returned of theResult) is theButtonIfPressedTheRuleWillContinue then
set theText to text returned of theResult
return {hazelExportTokens:{NewFilename:theText}}
end if
return {hazelExportTokens:{NewFilename:shortName}}
murr wrote:when i run the rule now, the pop up shows, i rename the file, click the button and nothing happens. the filename is the same as it was. the log file doesn't have any info to assist either.
## Working Code May 2019 ##
tell application "Finder" to set shortName to name of (theFile as alias)
set theDialogText to "Add New Details - Current Name: " & shortName
set theButtonIfPressedTheRuleWillContinue to "Rename This Image ?"
set theButtonIfPressedRuleAborts to "Skip Re-Naming ?"
set theDialogTitle to "Advanced Hazel Image Renaming"
tell application "Preview"
activate
open theFile
end tell
tell application "System Events"
activate
set theResult to (display dialog theDialogText with title theDialogTitle default answer shortName buttons {theButtonIfPressedTheRuleWillContinue, theButtonIfPressedRuleAborts} default button 1 giving up after 240 with icon (POSIX file (POSIX path of (get path to library folder) & "/PreferencePanes/Hazel.prefPane/Contents/Resources/Hazel.icns" as string) as string) as alias)
end tell
if (button returned of theResult) is theButtonIfPressedTheRuleWillContinue then
tell application "Preview" to quit
delay 0.8
set theText to text returned of theResult
return {hazelExportTokens:{NewFilename:"Go_ " & theText}}
--return {hazelExportTokens:{NewFilename:theText}}
end if
tell application "Preview" to quit
delay 0.8
--return {hazelExportTokens:{NewFilename:shortName}}
return {hazelExportTokens:{NewFilename:"Stop_ " & shortName}}