Rename file: Donaim

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

Moderator: Mr_Noodle

Rename file: Donaim Sat Mar 09, 2013 11:23 am • by Cassady
Hello all,

Not having much luck at the moment!

Have set up rules to move any (file) placed on my desktop containing with words "screen shot" in the (name), into a folder called [Screen Shots].

This works as planned.
Typically I simply use Shft+Ctrl+3 off any website.

My problem:

I added a [rename] condition prior to the [move], with pattern [name] and [domain].
The latter does not appear to be working.
Adding any other variables like [date created] [extension] does as expected, but the space where the [domain] name is supposed to be placed, remains blank.
I tested this by moving things around - [ext] [name] [domain] vs [ext] [domain] [name] vs [domain] [name] [ext], and in all cases - only [ext] and [name] appear in the renamed filed, with nothing at [domain].

I've tried different websites, and different browsers. No difference is made.

Any suggestions?
Cassady
 
Posts: 47
Joined: Wed Mar 06, 2013 4:34 pm

Re: Rename file: Donaim Mon Mar 11, 2013 12:04 pm • by Mr_Noodle
Domain is only filled in by programs which receive files from other locations and even then, only a handful of programs do it (namely Safari and Mail). If you select the file in Finder and do "Get Info", you can see this information in the "Where froms". Screenshots are taken locally so there is no metadata filled in for this.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Rename file: Donaim Mon Mar 11, 2013 12:46 pm • by Cassady
Mr_Noodle wrote:Domain is only filled in by programs which receive files from other locations and even then, only a handful of programs do it (namely Safari and Mail). If you select the file in Finder and do "Get Info", you can see this information in the "Where froms". Screenshots are taken locally so there is no metadata filled in for this.


Ah. Thanks for the explanation.
Cassady
 
Posts: 47
Joined: Wed Mar 06, 2013 4:34 pm

Re: Rename file: Donaim Mon Mar 11, 2013 5:53 pm • by a_freyer
if you give hazel a bit of time between screenshots, you can do this:

Code: Select all
if (all) of the following conditions are met for (the file or folder being processed):
     kind is image
     name contains "Screen Shot"

Do the following to the matched file or folder:
     run AppleScript (Embedded Script w/ Custom Token (• currentWebPage))
     rename (customWebPage •)
     ...


The embedded script is:

Code: Select all
tell application "Safari" to return {hazelExportTokens:{currentWebPage:URL of current tab of window 1}}


Make sure to add the Custom Token to the list as currentWebPage
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Rename file: Donaim Thu Mar 28, 2013 4:30 am • by Cassady
a_freyer wrote:if you give hazel a bit of time between screenshots, you can do this:

Code: Select all
if (all) of the following conditions are met for (the file or folder being processed):
     kind is image
     name contains "Screen Shot"

Do the following to the matched file or folder:
     run AppleScript (Embedded Script w/ Custom Token (• currentWebPage))
     rename (customWebPage •)
     ...


The embedded script is:

Code: Select all
tell application "Safari" to return {hazelExportTokens:{currentWebPage:URL of current tab of window 1}}


Make sure to add the Custom Token to the list as currentWebPage



Many thanks - this works a treat, but am I correct in that it would only function in Safari?

Tried replacing "Safari" with "Chrome" as the application in the script, and it picks up an error with my use of "current tab"...

Any thoughts?
Cassady
 
Posts: 47
Joined: Wed Mar 06, 2013 4:34 pm

Re: Rename file: Donaim Thu Mar 28, 2013 8:53 am • by a_freyer
Yes this is designed to work with safari. Look in the shrome AppleScript dictionary to get the current tabs source or domain.

For instance, this:http://stackoverflow.com/questions/2483033/get-the-url-of-the-frontmost-tab-from-chrome-on-os-x
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado


Return to Support