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
Zhenguo
PLEASE HELP!
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...
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.
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);
};
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.
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.
"\\" 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...
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??
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...
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!
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!
I'm inclined to post a link to a modified xpi file to save others some time, but I assume this is bad form.
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!
Can someone confirm on windows and mac with the current version on github?