ZotFile - Advanced PDF management for Zotero

1235763
  • Thanks Joscha for your answer.

    I noticed a problem when there are two attachments with one which is not of the specified format (pdf, doc, rtf, ...). In that case, nothing happens. I think the pdf file, for instance, should be processed. It is if the other attachment is deleted first.

    I will look how it would be possible to "merge" Zoterename functions into Zotfile, i.e. the ability to auto-execute Zotefile's renaming function whenever a file is attached during the creation of a reference.

    Thierry
  • edited November 22, 2010
    zotfile currently skips all items which have multiple attachments. I plan to change that in the future but currently you might run into problem because linked attachment might overwrite eachother. The plan is to change that. If you want to turn that off right now, you just have to make a small change in the RenameAttachments function:

    current code

    // for (var j=0; j < attachments.length; j++) {
    var j=0;
    if (attachments.length==1) {


    changed code

    for (var j=0; j < attachments.length; j++) {
    // var j=0;
    // if (attachments.length==1) {



    Let me know what you find out about automatically renaming any newly added files. I guess the easiest way would be to add an eventlistener which calls RenameAttachments whenever an attachment is added.

    Has anyone else played with the updated version?
  • edited November 23, 2010
    @Joscha: Thanks for updating your plugin.
    Do others also see the double reference for the functions in the drop-down menu?
    Yes. Have double entries in the menu for both of zotfile's two menu points.
    kithairon
  • edited November 24, 2010
    I observed the code of ZoteRename plugin and it gives me some insight on some questions we have about automatically renaming and also on:
    How I can make the zotfile options in the right click menu only appear for certain item types?
    Have a look at showRenameMenu in zoterename.js for this question in particular.

    Edit:
    The file "overlay.xul" should give you a sketch of solution to your other question:
    How to add the zotfile functions to zotero's paperclip drop-down menu?
    By the way, the file "options.xul" gives the way to make preferences easily accessible.

    Edit 2:
    I think that the duplication of options in the context-menu comes from the function createUI. In fact, when I comment this.createUI(), they appear only once. I do not completely understand for the moment how overlays are working, but it seems that it is loaded twice. By the way, what is mergeObserver doing?
  • edited December 5, 2010
    Just as an update: There will be a new version but currently there are still some bugs... I probably wont be able to solve them before Monday in a week...

    ps: Thanks Thierry. Unfortunately, I wasn't able to add zotfile to the attachment drop-down menu because I think it doesn't has an id so that I can't add anything to it...
  • I'm now using the Zotfile plugin to streamline photography of books and archival documents-- in combination with a tethered camera, it's great.

    I did have to edit the file type regex to add support for JPG -- it would be nice if images were supported by default, or if the list of types could be set in about:config. If you do add JPG, consider adding DjVu as well -- it has a decent following in Russia and probably some other parts of the world.

    I'm also exploring the possibility of calling an external program to pre-process the files -- I'll let you know if and when I have working code to add such a feature.
  • I've just finished working out a workflow for doing conversions -- it's a little clunky, but it works. See https://gist.github.com/734012

    I haven't put in the time to polish off the feature, but the idea is that I add a new menu entry to "Convert and attach". Zotfile calls an external executable that does something, then pulls in the output if that executable returned the expected exit code. The example Windows batch file on github make DjVu files out of JPEGs.

    Issues so far:
    -- My call to the external executable is blocking, so Firefox is frozen until the conversion completes. It should be easy to fix this, but I haven't really tried yet.
    -- The item attachment logic I'm using isn't flexible about file types-- the file extension consumed and produced by the external script should at least be defined by preferences and not hard-coded.
    -- I would like to add an option to disable renaming altogether; that'll happen later
    -- The work farmed out to the batch script could easily be done from within Firefox-- we could call conversion utilities right from Firefox just as well
    -- I hadn't written a Windows batch file for at around a decade and I plan to rewrite at least that part of it once I fix my wireless under Linux and move back to its more familiar confines.
    -- Multipage documents should be batched together into single DejaVu files.

    Anyway, I imagine that I'm not the only one taking extensive photographs of documents, so I'd appreciate the feedback of any intrepid souls who would like to try this out. I'll make an XPI when I'm back on Linux.
  • Here is a new test-version after some delay:

    http://www.columbia.edu/~jpl2136/zotfile_150b4.xpi

    This should now work with multiple items and some of the reported bugs should be resolved. As I mentioned earlier, it does not seem to be possible to add zotfile to the drop-down menu because I think it doesn't has an id so that I can't add anything to it...

    Reports are welcome...

    Happy new year!
  • Hi Joscha,
    Thanks for the update!

    I have tried it a few days and everything seem to work, though my testing may not encompass every aspect of Zotfile (e.g., I deal only with PDF).

    It doesn't matter for the "paper-clip drop-down menu", in my opinion; "one shot" button(s) might be more useful.

    I would like to add some suggestions of features if you wish to implement them some day:

    1. It would be great to enable automatic action (rename-move-link) whenever a file is attached —either through the source folder or through Zotero automatic download of references (see ZoteRename).

    2. Managing the option through a menu of preferences would be especially useful for the third point (see my preceding message for info).

    3. It would be wonderful to have a "tool" for the users in order to get different actions or options according to the types of files and/or the collections and/or source directory(ies)...
      By "tool", I mean the simplest way for both the programmer and the user to manage such functionnalities. I suppose that it may involve the user to code some lines; the aim would be to reduce these by predefined "module" that one can just copy/paste and change the parameters... (for example).

    I should admit that for know, these functionalities may look a bit superfluous with regards to current Zotero's ability with collections (e.g., no intersection of saved searches like in EndNote). However, I would really appreciate to classify my documents at different locations (or hierarchisation) according to their nature.

    Thanks again!
    Thierry
  • I should admit that for know, these functionalities may look a bit superfluous with regards to current Zotero's ability with collections (e.g., no intersection of saved searches like in EndNote). However, I would really appreciate to classify my documents at different locations (or hierarchisation) according to their nature.
    this is probably not the right place to discuss this, but Zotero Collections are very much like saved searches/virtual folders, so intersection is possible - if you have questions/requests on that, open a new thread so that this one remains focused on Joscha's great plugin.
  • edited January 17, 2011
    plugin works for me... Thanks!
  • Thanks for the report Thierry and Greg!!
    I am interested in automatic actions myself and I might implement it at some point. Can't really say when though - pretty busy right now... I don't think that I will do your other recommendations... sorry for that. You know that it's possible in the new version to put the pdf in different folders based on metadata from the item (e.g. different folder for journals)?

    A Bug: I think the plugin still does not work in new Firefox windows (not the one which opens when you start Firefox). I wasn't able to solve the problem even though some people pointed out a solution in this forum. Does anyone know what I need to change specifically?
  • In fact it was more suggestions or ideas than recommendations, and I certainly won't complain about a plug-in that is kindly develop on your spare time ;-)
    I will give it a try if I manage to allocate some time for it.

    I am not sure I understand your description of the bug you mention: by "new Firefox windows", you mean if one opens a link in a new window? Like with Maj+ clic?

    By the way, do you know why there is no icon (in the address bar) to directly insert a reference when a pdf is opened within the browser?
    Of course, this has nothing to do with the plug-in, but I wonder if this could be implemented in Zotero... It is obviously useful.
  • "do you know why there is no icon (in the address bar) to directly insert a reference when a pdf is opened within the browser?"
    Because there is no readable metadata on the page so a translator can't work - and there is only a URL bar icon when there is a translator.
  • OK, thanks.
    However, are there no metadata to be extracted from the PDF ? (even bad ones...) There is often no translator on websites where I open PDFs. Therefore, it would be very useful to fetch them directly ; in some sense in the same way as "snapshot of the page".
    Or do I miss a tip to do this by another quick way?
  • ah yes - if you click on "create new item from page" for a pdf, you then get the pdf by itself into Zotero - you can then right-click and use "Retrieve Metadata for pdf".
  • Thanks. But well, in fact, it does not work if in the preferences, the following is uncheck "Make an automatic capture of the page during the creation of an element from a Web page" (translated from french...).
    I unchecked it because otherwise it creates a useless snapshot of each webpage associated with an article from ScienceDirect or other platform.
    Besides, it takes more time than the clic on the icon (opening Zotero takes a while when the number of references are high).
    Anyway, that's at least a possibility.
  • The final version of 1.5 is finally online. It's now on mozilla add-ons:
    https://addons.mozilla.org/en-US/firefox/addon/zotfile/

    The new version supports batch processing of existing attachments, which I think a lot of people find useful (at least there have been frequent request about it). So you can basically change the zotfile renaming rules, select all your zotero items and rename all the attachment using data from the respective zotero item by clicking one button (please be careful with this option for now).

    Here is a summary of the new features:
    - Support for Firefox 4 and Zotero 2.1 (including support of zotero as a tab)
    - batch processing of existing attachments (renames and moves all attachments of selected items according to Zofile rules)
    - allows the user to organize files into subfolders using zotero metadata
    - bug related to multiple zotero windows resolved
    - The zotfile icon was replaced by two right-click menu items

    Let me know if you have any problems with the new version...
  • I finally decided to give this great plugin a try. Thanks Joscha for all the work.

    I installed and configured v1.5 as per the instructions but I cannot find any new menu items to actually use Zotfile. Am I missing something? I am on Win7 64bit, FF 3.6.13, Zotero 2.0.9

    Also, since you now allow users to organize files into subfolders based on metadata, would it be possible to use collection names in the rules? I know this would be quite a challenge with nested subcollections and you would have to pick a single collection if an iteam appears in more than one.
  • edited February 21, 2011
    I haven't used zotfile before, and I don't know the ins and outs of its features, but I just installed it over the multilingual branch, and it seems to work. I get a couple of items at the bottom of the context menu, and clicking on it offers to attach a file from my Downloads directory to the currently selected item. Clicking OK attaches the item, and renames it from the parent metadata. Looks like this could be quite handy. Thank you!
  • Hi,

    fbennett, are you using the 2.1beta or 2.0?

    Lubos, I am trying to figure out whether the current version only works with the Zotero 2.1beta. I had to made a change for the Zotero as a tab feature and now I am afraid that zotfile does not work with zotero 2.0 anymore. Can you try this version and tell me whether you can see the menu items when you right click a zotero item:

    http://www.columbia.edu/~jpl2136/zotfile_150_test.xpi
  • The multilingual branch is based on 2.1beta (actually the trunk itself, but that's close to 2.1beta at the moment).
  • Joscha, I have tried your link on Zotero 2.0.9 under Opensuse 11.3/Firefox 3.6.13 and it works, I can see the Zotfile menu items and they work as expected.

    Thanks for the great plugin, this makes Zotero much much more usable!
  • thanks katonag.... Can you try the version at

    http://www.columbia.edu/~jpl2136/zotfile_150_test.xpi

    again? I am trying to make it work for both 2.0 and 2.1...
  • Tried, works.
  • I have noticed, that the menu items only work, if they are selected from the parent items menu. When right clicking the attachment itself it won't rename. Additionally it only works for locally stored copies, and not for links to files. Maybe its not a bug, I'm new to ZotFile
  • okay, the version on mozilla addons is updated. You should get this one and not the one from columbia.edu so that zotfile is automatically updated...

    https://addons.mozilla.org/en-US/firefox/addon/zotfile/

    Here are the changes again:

    The new version supports batch processing of existing attachments, which I think a lot of people find useful (at least there have been frequent request about it). So you can basically change the zotfile renaming rules, select all your zotero items and rename all the attachment using data from the respective zotero item by clicking one button (please be careful with this option for now).

    Here is a summary of the new features:
    - Support for Firefox 4 and Zotero 2.1 (including support of zotero as a tab)
    - batch processing of existing attachments (renames and moves all attachments of selected items according to Zofile rules)
    - allows the user to organize files into subfolders using zotero metadata
    - bug related to multiple zotero windows resolved
    - The zotfile icon was replaced by two right-click menu items
  • edited February 22, 2011
    Sorry, mistaken post.
  • edited February 22, 2011
    Is it possible to rename individually?
  • What do you mean? Do you mean selecting an attachment and then renaming it? Currently not, but I thought about implementing that...
This discussion has been closed.