Prompt to rename a file

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Prompt to rename a file Sat Feb 19, 2022 4:27 am • by goat
Hi guys,

I am trying to do something pretty straight forward. This worked in my old Mac but now on Monterey in the new iMac the Applescript throws an error.

I am trying to simply:
1. Move a file that has a specific tag into a folder.
2. This folder has renaming rules already -> so once the file gets there, it gets renames based on those rule
3. The Applescript prompts a pop up that asks me to rename the file according to a specific naming convention (I need to define in this case manually part of the file name, this is the reason for the rename prompt)

Here is what I have in the Applescript
Code: Select all
delay 3
tell application "Finder" to activate
tell application "Finder"
   set currentName to name of theFile
   set name of theFile to text returned of (display dialog "Rename File:" default answer currentName)
end tell


This is the error I get
error "The variable currentFile is not defined." number -2753 from "currentFile"


Here is my Hazel ruleset
https://drive.google.com/file/d/1oqO8Y28XjEvWHjoTYvxzB64GEwf266np/view?usp=sharing

I've played around with the "delay" to give enough time for the other rules to run first, but makes no difference.

What am I doing wrong?

Thanks!
goat
 
Posts: 9
Joined: Fri Mar 06, 2020 7:38 am

Re: Prompt to rename a file Mon Feb 21, 2022 9:50 am • by Mr_Noodle
Renaming the file in the AppleScript like that may not be the best approach. Instead, I recommend creating a custom attribute in your script and returning that to Hazel. Hazel can then use that in a Rename action.
Mr_Noodle
Site Admin
 
Posts: 11867
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Prompt to rename a file Wed May 11, 2022 7:27 am • by goat
Mr_Noodle wrote:Renaming the file in the AppleScript like that may not be the best approach. Instead, I recommend creating a custom attribute in your script and returning that to Hazel. Hazel can then use that in a Rename action.


Thank you.

Is there an article(s) or post(s) you can point me to figure out how to do that? I have no idea from where to start from.
goat
 
Posts: 9
Joined: Fri Mar 06, 2020 7:38 am

Re: Prompt to rename a file Wed May 11, 2022 8:32 am • by Mr_Noodle
Try searching the forums here. There might be a similar script someone else has done.

Also check the manual for how to integrate scripts with Hazel in general.
Mr_Noodle
Site Admin
 
Posts: 11867
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support