zotfile can not move files into subfolders based on collections in Windows

For example, I have one pdf file in the collection Literature->Biology, and I set up the option "Use subfolder defined by" to "\%c". Zotfile to move files into subfolder "LiteratureBiology" when I used Zotfile's rename attachments functions. I have spent one day to fix this problem by modifying the code, but I could not make it work. I think that the problem is the returned path having path separator '/' which is not recognized by Windows. Could you please check and fix this problem? Thank you.

Zhenguo
  • *push* exactly the same for me. The zotfile discussion thread suggests that the majority of users are apple-yogis (on MacOS it seems to work, which makes sense because those linuxes uses the forward slash).

    PLEASE HELP!
  • from the ZotFile thread:

    Okay, strike out question 1. I just modified "/%y /%w" to "/%y\/%w" (Windows OS) and I got the nested subfolder that I wanted!
    I assume that'll work.
  • edited August 31, 2015
    @adamsmith: Sorry, it doesn't!

    See initial post, example: Using %c in "Use subfolder defined by" (nothing else like %y or %w) moves an attachment "attachment.pdf" in the subcollection "Biology" under the collection "Literature" erroneously to:
    ...\LiteratureBiology\attachment.pdf
    It should be:
    ...\Literature\Biology\attachment.pdf

    In other words: the collection path (%c) does not get separated into subdirectories, which is most probably a problem in the API, since the zotfile .js-sourcecode seems to be correct. This makes the whole move/rename module UNUSABLE for windows users. Please help...
  • oh right, misread that. How about using the Send to Tablet function with the subfolder option checked -- does that not work on Windows either?

    This is almost certainly an issue in ZotFile code and it's on Joscha's bugtracker marked as such:
    https://github.com/jlegewie/zotfile/issues/179
    (The Zotero API doesn't have anything to do with writing to the disk, so if it's not ZotFile it's a Firefox issue, which is not impossible but unlikely.)

    Best change is probably if someone else digs in and submits a patch. I know Joscha is quite busy these days and troubleshooting on Windows is probably not high on his agenda.
  • edited September 22, 2015
    Thank you for the bugtracker issue - right, that´s it. Looking into it... please stand by...

    I assume that it is the following function in the source file zotfile.js (NOT zotero.js, sorry for the mistake in original post):

    wildcardTable: function(item) {
    var getCollectionPathsOfItem = function(item) {
    var getCollectionPath = function(collectionID) {
    var collection = Zotero.Collections.get(collectionID);
    if (collection.parent == null) return collection.name

    return getCollectionPath(collection.parent) + "/" + collection.name;
    };

    return item.getCollections().map(getCollectionPath);
    };
  • Yeah, it works: changing the following line

    return getCollectionPath(collection.parent) + "/" + collection.name;

    to

    return getCollectionPath(collection.parent) + "\\" + collection.name;

    works as expected, for windows only, of course. The platform-independent coding should be:
    return getCollectionPath(collection.parent) + this.folderSep + collection.name;
    but this does not work... therefore, the issue remains open, but this workaround above works, creating a windows-specific xpi file for the zotfile plugin.
  • Have you tried to debug this? this.folderSep should just return "\\" on Windows so I can't see how this would fail.
    Brings me back to my question about send to tablet, though: does it work there? If not, there would seem to be something off with the folderSep definition (which that part of the code does use).
    If it does work there, you'd want to try to add some debugging code there to listen in what it does with collection paths.
  • edited September 1, 2015
    ...of course I did, see my comment in the last sentence, I repeat in summary:

    "\\" works (for Windows)
    "/" works (original, for Apple, I assume)
    this.folderSep don´t work

    The latter is probably the reason why the author uses "/" hard-coded. I assume that there is a problem with the recursive call and the return parameter. And: the copy-to-tablet works as intended, as well as my workaround for the move-and-rename function above...
  • @m.halber
    Ican't repeat the result!I searched my whole copmuter to find the file "zotero.js" and finally found it in the Firefox's extension catagory : C:\Users\"User's name"\AppData\Roaming\Mozilla\Firefox\Profiles\5zlslho9.default\extensions\zotfile@columbia.edu.xpi ; In this xpi file ,a javascript named zotfile.js has the content.and i do what m.halber described by changeing the "/" to "\\" . Finally it shows in firefox as untrusted extenstion,and doesn't work,just doesn't reply my clicking the "zotfile preference" in zotero. What im supposed to do to acchive this goal??
  • edited September 22, 2015
    @myxiaosha: you have to reinstall the zotfile extension with the modified zotfile.js (NOT zotero.js) (I used winzip for that)

    I hoped that the zotfile-author or adamsmith or anyone else would be so brave to solve this issue. If not, then every windows user is forced to apply this workaround. Obviously too many apple fanboys out here...
  • I'm happy to hear it gets reply ,thank you ! But sadly, it still doesn't work, though i do as you said. I need thoes questions to be clarified below.
    1. we should modify the file "zotfile.js" but not "zotero.js" ,right?(ps: zotfile.js locates in C:\Users\"User's name"\AppData\Roaming\Mozilla\Firefox\Profiles\5zlslho9.default\extensions\zotfile@columbia.edu.xpi )
    2. I take the following steps :
    2.1 rename the file:"zotfile@columbia.edu.xpi" to "zotfile@columbia.edu.xpi.zip";
    2.2 open it with 7zip ,extract the file "zotfile.js";
    2.3 modify extracted file "zotfile.js" by changing the "/" to "\\" with notepad.exe and save the changes ;
    2.4 insert the modified file to the place where it extracted thus to replace the orignal file.
    2.5 open the xpi with firefox to reinstall it.

    The result is that, when i want to rename my attachments or open zotfire preferences or anything , it ignores my orders ,just like nothing happens.

    so, you see , I'm killing myself to solve the problem, now on the way of crazy!
  • Yes, you are right, it´s not zotero.js but zotfile.js, thank you for exemplifying this...

    Please be aware that you have to REINSTALL the xpi extension. Therefore, I would recommend not to mess around with the Profiles folder, but REMOVE the extension, DOWNLOAD the xpi file from the extension source, and do the things you mentioned. I am using the standalone version. That was the way I did it, sorry for being so brief. Good luck!
  • @m.halber Now I'm sure this method doesn't work on the firefox extension edition. So I turn to the standalone .I download the source code of zotfile for standalone in https://github.com/jlegewie/zotfile/releases and don't konw how to use it. Really need your help,thanks so much!
  • See https://github.com/jlegewie/zotfile#installation
  • Thanks for the info, guys. I wish this forum had a "kudos" button or something to avoid cluttering the thread with thank-you notes.

    I'm inclined to post a link to a modified xpi file to save others some time, but I assume this is bad form.
  • Just wanted to confirm that this works, amazing, thank you so much!!!

    If myxiaosha or anyone else is still having problems to make it work, most likely is because they are using the notepad in windows to modify "zotfile.js", try using a good editor like "sublime" instead.

    Thanks again, it made a huge difference for me!
  • Just tried to fix this. https://github.com/jlegewie/zotfile/issues/179
    Can someone confirm on windows and mac with the current version on github?
  • Joscha, I tested it on Windows 7 (Zotero for Firefox) and the issue seems to be resolved, much thanks!
Sign In or Register to comment.