Prompt to Rename Files

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

Moderator: Mr_Noodle

Re: Prompt to Rename Files Fri Apr 06, 2012 1:32 pm • by a_freyer
One more step! :-) You have to rename the file yourself!

Sorry, I should have been more clear:

Image
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Prompt to Rename Files Fri Apr 06, 2012 2:32 pm • by murr
beautiful.. works like a champ. thank you so much for your help. i really do appreciate it.
murr
 
Posts: 8
Joined: Wed Apr 04, 2012 9:23 pm

Re: Prompt to Rename Files Fri Apr 06, 2012 2:39 pm • by a_freyer
Happy to help.

As written, the "skip file" button doesn't do much. In fact, I think it will probably duplicate the extension. I'd suggest looking at the AppleScript, and modifying the tags at are returned in the event of a skip file button press.

For instance, you could change the tag to shortName & "-skipped" and then add a filtering mechanism in the rule itself:

Code: Select all
If (all) of the following...
     ... Same ...
     NAME does not match Screen Shot (...)skipped(...)

then
    ... Same ...


Something like that.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Prompt to Rename Files Mon Apr 09, 2012 11:16 am • by Mr_Noodle
I can't see the screenshots but after the Run AppleScript action, are you doing a rename? If not, you need to have Hazel rename the file. All the script does is bring up the dialog and then pass that info back into Hazel. When renaming, that exported token should appear in the list for you to use.

[EDIT: Whoops. Missed the second page of this thread. Looks like it was already explained]

Also, a_freyer, thanks for fielding many of the questions here. You've been on a roll lately.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Prompt to Rename Files Mon Apr 09, 2012 11:20 am • by murr
yes.. the dialog box appears and allows me to perform a rename. this is working great for me. i can't even begin to tell you how much time this has saved me just in the past few days. thanks again a_freyer.
murr
 
Posts: 8
Joined: Wed Apr 04, 2012 9:23 pm

Re: Prompt to Rename Files Mon Apr 09, 2012 11:23 am • by a_freyer
Glad to help!
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Prompt to Rename Files Wed May 23, 2012 3:17 pm • by Shawn Wright
This is very helpful recipe but I am having a little trouble and was hoping someone could take a look at this and advise me. I have it setup as

Run AppleScript > embedded script

Code: Select all
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 with icon (POSIX file (POSIX path of (get path to library folder from user domain) & "/PreferencePanes/Hazel.prefPane/Contents/Resources/Hazel.icns" as string) as string) as alias)
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}}


Rename > with Pattern: > •NewFileName, extension
Move > to folder: > Action

Everything seems to work well and moves to the correct place but my filename does not change to what is in my popup window but only changes to pdf, pdf-1, pdf-2, etc. (all the files are pdf's)

Any thoughts?

Thanks,

Shawn
Shawn Wright
 
Posts: 5
Joined: Wed May 23, 2012 3:11 pm

Re: Prompt to Rename Files Wed May 23, 2012 4:15 pm • by a_freyer
What is the matching section of your rule? Can you take a screenshot of the rule & content?

Code: Select all
if (all) of the following...
    Something to match your file <-- the applescript DOES NOT go here.

then
    Run AppleScript (exporting NewFilename) <-- This is where the applescript goes
    Move, or whatever else.


EDIT - See answer below.
Last edited by a_freyer on Thu May 24, 2012 12:22 pm, edited 1 time in total.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Prompt to Rename Files Thu May 24, 2012 10:17 am • by Shawn Wright
Can I post images to this forum or do I need to link? I can't quite figure it out.
Shawn Wright
 
Posts: 5
Joined: Wed May 23, 2012 3:11 pm

Re: Prompt to Rename Files Thu May 24, 2012 10:46 am • by a_freyer
The forum does not host images. Most people use Dropbox or something similar to host.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Prompt to Rename Files Thu May 24, 2012 11:09 am • by Shawn Wright
Nothing like needing help to use the help forum. Anyway, here are the screen shots, I believe this might be what you are asking for.

Image

Image
Shawn Wright
 
Posts: 5
Joined: Wed May 23, 2012 3:11 pm

Re: Prompt to Rename Files Thu May 24, 2012 11:48 am • by a_freyer
It doesn't look like anything is wrong with your script or your layout. Can you give an example of the name of a file that fails the rule?

Or better yet, could you export the rule and post it here so I can debug it for you?
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Prompt to Rename Files Thu May 24, 2012 12:03 pm • by Shawn Wright
Here you go. Could it have something to do with the moving part?

https://www.dropbox.com/s/4errjluv3vcm4tb/Pictures.hazelrules
Shawn Wright
 
Posts: 5
Joined: Wed May 23, 2012 3:11 pm

Re: Prompt to Rename Files Thu May 24, 2012 12:16 pm • by a_freyer
EDIT - Nothing to do with the moving. See answer below.
Last edited by a_freyer on Thu May 24, 2012 12:22 pm, edited 2 times in total.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Prompt to Rename Files Thu May 24, 2012 12:21 pm • by a_freyer
I see the problem:

In your "Name Tokens" box, you have input "NewFileName", but in your script you have "NewFilename"

These must match - after that, the rule works great for me!

Hope this helps! :-)


Moral: When using Hazel Export Tokens, make sure the Script Token Name exactly matches (case sensitive) the Token Naming dialog
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

PreviousNext

Return to Support