On Nov 18, 2011, at 6:58, FZiegler wrote:

> Following your advice, I produced the following as my first applescript ever, 
> and would like your help improving it.
> 
> using terms from application "BibDesk"
>       on perform BibDesk action with publications thePubs for script hook 
> theScriptHook
>               repeat with thePub in thePubs
>                       tell thePub
>                               set thePath to (get POSIX path of linked files)
>                               set thePath to do shell script "echo " & 
> thePath & "|sed -e \"s|$HOME|~|\""
>                               set value of field "Local-Url" to thePath
>                               set value of field "Bdsk-File-1" to ""
>                       end tell
>               end repeat
>       end perform BibDesk action with publications
> end using terms from
> 
> Saved it as "~/Library/Application Support/BibDesk/Scripts/unalias.scpt" and 
> assigned it to the "Did Auto File" hook in BibDesk's Script Hooks preference 
> pane.
> 
> This mostly works -- i.e., on dropping a file the Local-Url field gets filled 
> with e.g. ~/Documents/Math/Archive/B/Benoist.Y/Benoist.1995.pdf -- but there 
> remain two problems:
> 
> 1) The line `set value of field "Bdsk-File-1" to ""' has no effect. It is 
> meant to erase that field, but it seems it either doesn't or the field gets 
> regenerated on every save. Is there a better way that would actually remove 
> it?
> 

You should never access those fields. Those fields only exists in the saved 
file, they don't exist in the program. You only have the linked files, so if 
you want to remove them you should delete those.

> 2) When the author's name has diacritics, what gets written to the file is 
> different than it used to with version 1.3.12. At first sight (in BibDesk's 
> interface) it looks the same, but in a text editor one sees that an Š, for 
> instance, gets written Š (hex: 53 CC 8C) instead of Š (hex: C5 A0); see 
> attached screen shot. While these may be different "decompositions" of the 
> same unicode character (I haven't checked yet), it seems likely to bite me in 
> the long run. Does anyone know the magic incantation that would keep things 
> consistent?
> 
> Thanks,
> Francois


Yes, this is the decomposed S + caron and the combined S-with-caron 
respectively. What you get is fairly unpredictable, different methods will give 
different results, all kinds of processes can change the composition. That's 
the problem with Unicode. I wouldn't really know how to normalize that. I don't 
know why it would bite you, most methods you would use should not make a 
difference between different decompositions.

When you use a path in a shell script, you should always quote the path. In 
AppleScript you can conveniently do that by using "quoted form of thePath". 

Also, there can be multiple linked files. So getting "POSIX path of linked 
files" gives you a *list* of strings. So you should get something like "POSIX 
path of linked file 1". And you should first check whether there are linked 
files, and also whether the Local-Url isn't overwritten or unnecessarily set.

And it's probably better to add a line "set thePub to contents of thePub" right 
after the repeat, because AppleScript often has problems with that.

Christiaan


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Bibdesk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users

Reply via email to