Adding a line

“tell thePub to auto file”

before the last two end tells should do it.

On 27 Sep, 2014, at 08:41, Antonio Fortin <[email protected]> 
wrote:

> Okay, I’ve managed to get things working, more or less. I mistakenly thought 
> the script was doing nothing, because nothing would happen visibly and, then, 
> searching for the papers I was trying to add in BibDesk would find nothing. 
> However, I tried the following, and it also selects the new paper:
> 
> `
> set posixPath to POSIX path of theFile
> set newPDF to POSIX file posixPath
> tell application "BibDesk"
> if (count of documents) is 0 then make new document
> tell front document
> set thePub to make new publication
> add newPDF to thePub
> select thePub
> end tell
> end tell
> `
> 
> There’s one more thing I’d like the script (or BibDesk) to do at the end, and 
> that’s to either move or copy the linked PDF into the BibDesk papers folder. 
> I’ve set the location for BibDesk to file papers, and I’ve also set it to 
> file papers automatically (see attachment), but this doesn’t happen. The PDF 
> remains in the location I saved it in.
> 
> <screenshot.png>
> 
> Thanks for your help with this Christiaan!
> 
> Best,
> Antonio
> 
> PS. I have no idea what the MS Office-related BibDesk errors were about, but 
> they’re not happening any more.
> 
> 
> On 27 Sep 2014, at 16:40, Christiaan Hofman <[email protected]> wrote:
> 
>> 
>> On Sep 27, 2014, at 15:32, Antonio Fortin wrote:
>> 
>>> On 27 Sep 2014, at 14:20, Christiaan Hofman <[email protected]> wrote:
>>> 
>>>> On Sep 27, 2014, at 14:07, Antonio Fortin wrote:
>>>> 
>>>>> The Hazel rule I have does exactly that. I’ve tried running the script on 
>>>>> its own, specifying an actual PDF rather than `theFile` (see below), and 
>>>>> nothing happened.
>>>>> 
>>>>> `
>>>>> tell application "BibDesk"
>>>>> if (count of documents) is 0 then make new document
>>>>> tell front document
>>>>> set thePub to make new publication
>>>>> add "MBA:Users:antonio:foo.pdf" to thePub -- replace with path to your 
>>>>> own PDF
>>>>> end tell 
>>>>> end tell
>>>>> `
>>>>> 
>>>>> —Antonio
>>>>> 
>>>> 
>>>> That's a string, not a file object. You need to convert it to a file. So 
>>>> something like 
>>>> 
>>>> POSIX file "/MBA/Users/antonio/foo.pdf"
>>>> 
>>>> or
>>>> 
>>>> alias  "MBA:Users:antonio:foo.pdf"
>>>> 
>>>> (file "MBA:Users:antonio:foo.pdf" should work in theory but does not work 
>>>> in practice.)
>>>> 
>>>> That does work for me.
>>> 
>>> This *should* do it, right?
>>> 
>>> `
>>> set posixPath to POSIX path of theFile
>>> set newPDF to POSIX file of posixPath
>> 
>> set newPDF to POSIX file posixPath
>> 
>> (leave out the "of")
>> 
>>> tell application "BibDesk"
>>> if (count of documents) is 0 then make new document
>>> tell front document
>>> set thePub to make new publication
>>> add newPDF to thePub
>>> end tell
>>> end tell
>>> `
>>> 
>>> However, it doesn’t. Console shows a few BibDesk errors whenever I execute 
>>> this script, but they have to do with MS Office and Spotlight. It looks 
>>> like this is what’s causing the problem, but I have no idea how to go about 
>>> fixing it.
>>> 
>> 
>> That's strange. What errors? It seems their dictionary are messing up the 
>> language. that is actually far too common with AppleScript (one reason why 
>> it's such a failure of a language.)  Though it should not do this here, as 
>> it's all in a "tell application "BibDesk"" block. Perhaps there are 
>> scripting extensions in your ~/Library/ScriptingAdditions from those apps?
>> 
>> Christiaan
>> 
>>> Oh well, I’ll keep looking. Thanks for your help, Christiaan. If you have 
>>> any ideas on how to fix this problem, I’d love to hear them.
>>> 
>>> —Antonio
>>> 
>>> 
>>>>> On 27 Sep 2014, at 13:52, Christiaan Hofman <[email protected]> wrote:
>>>>> 
>>>>>> Of course this script won't do anything by itself. It is not complete, 
>>>>>> it is just a fragment for the relevant part related to BibDesk. You have 
>>>>>> to somehow pass the file to the script. I don't know if and how Hazel 
>>>>>> can do that.
>>>>>> 
>>>>>> Christiaan
>>>>>> 
>>>>>> On Sep 27, 2014, at 13:06, Antonio Fortin wrote:
>>>>>> 
>>>>>>> Hi Christiaan,
>>>>>>> 
>>>>>>> Many thanks for that. However, when I trigger the script in Hazel, the 
>>>>>>> PDF in question doesn’t get added to BibDesk. I know that the rest of 
>>>>>>> the rule is working, because it does other things (like remove the tag).
>>>>>>> 
>>>>>>> I suspect I haven’t set it up correctly, however. I’ve attached a 
>>>>>>> screenshot of the rule. Does it work for you, as it is?
>>>>>>> 
>>>>>>> I’ll almost always want to import to an existing library when BibDesk 
>>>>>>> is already running, so I’m not worrying about the conditional statement 
>>>>>>> or activating BibDesk just yet.
>>>>>>> 
>>>>>>> Thanks again.
>>>>>>> 
>>>>>>> Best,
>>>>>>> Antonio
>>>>>>> 
>>>>>>> <hazelBibDesk.jpg>
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> On 26 Sep 2014, at 23:04, Christiaan Hofman <[email protected]> wrote:
>>>>>>> 
>>>>>>>> 
>>>>>>>> On Sep 26, 2014, at 19:54, Maxwell, Adam R wrote:
>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> On Sep 26, 2014, at 08:17, Christiaan Hofman <[email protected]> 
>>>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>>> AppleScript could very well do this. But how to write that 
>>>>>>>>>> AppleScript really depends on how you want to use it and what you 
>>>>>>>>>> want precisely to do. Probably you need some AppleScript like the 
>>>>>>>>>> following (here I assume theFile is the file you want to add):
>>>>>>>>> 
>>>>>>>>> The same script would also work if you have BD set to open a 
>>>>>>>>> particular .bib file at launch, right? That would allow the OP to 
>>>>>>>>> append new PDFs to the same .bib database.
>>>>>>>>> 
>>>>>>>>> Adam
>>>>>>>>> 
>>>>>>>> 
>>>>>>>> Yes, it should. Though if you want to apply this also in cases where 
>>>>>>>> BibDesk should launch, then you probably also want to add an 
>>>>>>>> "activate" command somewhere. And I can imagine there may be timing 
>>>>>>>> issues (i.e. it checks for the count of documents before the initial 
>>>>>>>> file was launched), though a quick test does seem to work.
>>>>>>>> 
>>>>>>>> Christiaan
>>>>>> 
>>>>>> ------------------------------------------------------------------------------
>>>>>> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
>>>>>> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
>>>>>> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
>>>>>> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk_______________________________________________
>>>>>> Bibdesk-users mailing list
>>>>>> [email protected]
>>>>>> https://lists.sourceforge.net/lists/listinfo/bibdesk-users
>>>>> 
>>>>> ------------------------------------------------------------------------------
>>>>> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
>>>>> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
>>>>> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
>>>>> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk_______________________________________________
>>>>> Bibdesk-users mailing list
>>>>> [email protected]
>>>>> https://lists.sourceforge.net/lists/listinfo/bibdesk-users
>>>> 
>>>> Christiaan
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
>>>> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
>>>> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
>>>> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk_______________________________________________
>>>> Bibdesk-users mailing list
>>>> [email protected]
>>>> https://lists.sourceforge.net/lists/listinfo/bibdesk-users
>>> 
>>> ------------------------------------------------------------------------------
>>> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
>>> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
>>> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
>>> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>>> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk_______________________________________________
>>> Bibdesk-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/bibdesk-users
>> 
>> Christiaan
>> 
>> ------------------------------------------------------------------------------
>> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
>> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
>> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
>> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk_______________________________________________
>> Bibdesk-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/bibdesk-users
> 
> ------------------------------------------------------------------------------
> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk_______________________________________________
> Bibdesk-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bibdesk-users

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Bibdesk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users

Reply via email to