Filename script help

Hey there I am searching for a script to do the following

I would like to manually select the pdf file I want to rename and then select some text from the file and run the smart rule and the select text should become the new filename.
I bet it is easy but not good with AppleScript right now

I wanted to view the dictionary in apple script but it seems it doesnt work. I can select the devonthink dictionary in apple script but nothing opens up

You don’t need a script for this :smiley: Just right click on the selected text and choose Set Name As. Also available in the Edit menu. The default keyboard shortcut for the command is ^⌘I

I don’t know what’s going on with you AppleScript dictionary, it works fine for me.
(… Just to make sure: You need to double-click the dictionary to launch it, or choose “Open dictionary” in the library toolbar. It is not enough to only select it.)

thanks for the hint with set name as. that is cool. BUT I would still need it as a part of a script because I have a smart rule that does more with the filename besides using the select text . basically I want to have 2 or 3 different things as the filename and the last part of the filename should just be the selected text.

In regard to the AppleScript dictionary that’s what I did but still nothing is displayed then

Alright. You didn’t list any other steps, so I just thought: No reason to complicate something very simple :wink:

I don’t know what what to tell you about the dictionary. That is strange. Do you use multiple monitors or something? My first guess is the window opens but is hidden somewhere.

Can you open other dictionaries?

Does it make a difference if you open it from the Library? (Window > Library). This window:

I don’t know why that would make a difference, but might as well try.

I don’t know AppleScript and have only tried looking a bit in the dictionary. So I don’t think I can be of further help.

You can fill in the rest, but generally you’ll want the script to

set theText to selected text of think window 1

and then later

set the name of theDocument to theText

Your script of course will need to ensure there is a document selected, that there is text selected, etc. (In my example above theText and theDocument are placeholders for your own variables.) If you want the name to end up as a composite of the selected text plus other data, then you’ll have statements to in the script to do the appending before set the name… occurs.

1 Like

thanks now the devonthink dictionary is open had to do it form window add library then it appeared.

still if others can help with creating a script to add the selected text as a part of the filename I would appreciate it

Sometimes the dictionary would not open on my first attempt. The second attempt always works. I don’t know about the cause though; it’s been like this on my device for as long as I can remember.

Check out DT’s built-in scripts in the Rename section.

So strange. I can’t write AppleScript – but I never had a problem opening the dictionary! Is it some curse you gain along with mastering the dark arts? :smiley:

Joking aside – yes, looking at examples is helpful. I have been looking at some of them trying to get a feel for the structure and syntax.

I use a script to assist with processing inbox entries; formatting filename, assigning tags, etc

Click to see script code for formatting filename
tell application "System Events" to keystroke "c" using {command down}
set theSelectedText to the clipboard

tell application id "DNtp"
	set selectedNotes to get selection
	repeat with selectedNote in selectedNotes
		set theName to name without extension of selectedNote

		set theNewName to theName & theSelectedText*

		set name of selectedNote to theNewName
	end repeat
end tell
1 Like