Home-dir-relative storage of linked files.

13
  • edited December 29, 2011
    you can change the dynamic named folders inside zotero storage
    Don't do this. The storage folder is not meant to be touched outside of Zotero. And the item key is part of core internal logic—it's about much more than where files are stored, and it absolutely shouldn't be changed manually.
  • One more vote for relative path !
  • I use Zotero on an external drive in Windows (XP and 7) so that I can access my library wherever I go. To get around the relative paths problem I make sure that my external drive is assigned the same drive letter no matter which computer I am on. In my case, Y:\ is available anywhere I go.

    To change a drive letter, I use DriveLetterView (http://www.nirsoft.net/utils/drive_letter_view.html) which works on all versions of Windows 2000/XP/Vista/7. However, you need administrator rights.

    An alternative is to map a folder to a particular drive letter. The Windows 2000/XP/Vista/7 command SUBST does this, or you can use Visual Subst (http://www.ntwind.com/software/utilities/visual-subst.html).

    Both programs are portable, i.e. they do not need to be installed.
  • Just checking -- would the devs be willing to implement a patch for this if submitted? I think I could do this, if so.
  • If it works well and doesn't cause any problems, probably. Might be a good idea to post to zotero-dev with an overview of how you see yourself implementing it.
  • I found mc's second method, Visual Subst, is particularly useful. Visual Subst is a portable program and does not require admin rights to work.

    For those of you who already have lots of attached links, it is easy to move them to the new folder. You only need to open the zotero database and execute the following sql in a sqlite manager (e.g. http://portableapps.com/apps/development/sqlite_database_browser_portable):

    update itemAttachments set path = "V:" || substr(path, length('D:\Dropbox\Dropbox')+1, 999) wh_ere path like "D:\Dropbox\Dropbox%"

    I just found I cannot submit with wh_ere (delete '_')

    1. Backup your database before make any changes.
    2. This change will not be synced automatically, so you have to run it on different computers.
  • It is a good news that willshanks Jan 19th 2012 said that there might be a patch sumitted for this!

    If use only in windows or only in linux, this path problem is not-so-difficult to resolve by hand:
    1) In windows we can reassign the USB Key a new driver letter or using Visual Subst, see post of mc Jan 11th 2012;
    2) In linux we could make a soft link, see post of fbennett Jan 7th 2009 edited ;
    In both case we could get the same path link without any change in the zotero.sqlite!

    But with cross-plaform on different OSs, there still be problem because of path structure is different.I have issues the same with some of you when transfer the zotero database and lots of PDFs from Windows to Linux.

    Some of PDFs saved automatically in the zotero-storage-path(.../zotero/storage/xxxx) give right links to file directly after the the re-setting of zotero profile path(this is a very good feature employing relative path). But other link-to-file attachments still hold the path under Windows which was not what we want,they should be re-linked.

    After try and get database damaged many times, finally I succeeded by using sqlite3 and sed.

    My former PDFs are stored in I:\zotero\doc\papers\, and in linux it is mounted to /media/w/zotero/doc/papers/. Now comes the solution(under debian Linux with sqlite3 installed):
    1) stop firefox to make zotero.sqlite usable, make a backup:
    $ mv zotero.sqlite 1zotero.sqlite

    2) dump the database using sqlite3, pipe it to sed to change the path, then pipe it again to sqlite3 to create a new database:

    $ sqlite3 1zotero.sqlite ".dump"|\
    sed -e 's/I:\\zotero\\doc\\papers\\/\/media\/w\/zotero\/doc\/papers\//g'|\
    sqlite3 zotero.sqlite


    By the way, before using sed together with sqlite3 I try only use sed to do the change but with database damaged.

    3) restart firefox

    At a first glance it works well with firefox and the PDFs are in right link. and I keep two version of zotero.sqlite,one for windows,one for linux.

    Hope this could be helpful for you for the moment before the patch!

    I really appreciate these ideas:
    1) Home-dir-relative storage of linked files;
    2) auto-saving of PDFs configurable;
    3) user-path PDFs auto-scannable to add to database;

    Thank your for reading this!


    notius
  • Dear Everybody,

    another solution would be to allow "attach link to file" in the groups and use the "zotfile" plugin for firefox that already manages the links to file...

    Am I right?

    All the best, Laurent
  • Hi folks,
    Has the patch been added? I'd really like to see something like this. I dual-boot Ubuntu and Windows 7 and zotero is so integral to my computing behaviour that the lack of cross-platform access is really a huge dissuasion to use linux (my database is all windows based, so I'm forced to use windows all the time now).

    I'd be willling to run a little shell file to manually copy / edit the sqlite file over to Linux, and it looks like notius's method ( notius Feb 14th 2012) is the best option.
  • no, the patch is submitted but still in the queue:
    https://github.com/zotero/zotero/pull/51
    once it gets accepted (assuming that it will - I have no insight there) it will probably make it into the trunk for the next major Zotero release.
  • It is probably best to try one of the other solutions suggested above rather than waiting for the patch. An unrelated patch I submitted five months ago was accepted around three months ago (if I recall correctly) and is still waiting for the next major release to become part of Zotero. The relative path patch was submitted three months ago, and I am not sure when it will get looked it. If I had to guess, I would say that it will not be accepted as-is but will require some adjustments. So the time frame for that patch becoming part of Zotero is probably many months.
  • This patch was looked at --- Simon gave some feedback two months ago and the patch author hasn't yet made his promised changes. Once that patch comes in, we can assume that Dan will look as well and perhaps the patch will land.
  • I am the patch author. The only change is the deletion of one "while" statement because the code always exits the loop after one iteration any way. I did not realize that this change was holding up the review of the patch. I was waiting to receive feedback from Dan before submitting such a trivial change, but I will make it now.
  • Right-- sorry about that. I wasn't sure whether that was you. I realize that the change is small, but making that change would help move the process along. Changes like this help show that the patch author is responsive and ready to shepherd the patch towards landing. It probably will still take time-- the core team is tiny and chronically short of time-- but that puts the ball in Dan & Simon's court.
  • No problem. Thanks for pointing out that the patch was waiting for me. Otherwise I don't know how long I would have left the patch sitting idle. I know the developers are short of time, so I didn't want to bother asking them about the status of the patch because I know that they can see the pull request in the list on github but have other priorities.
  • The pull request by willshanks is still open on github after about 3 month. Isn't it going to be merged into the official release? This feature seems to be needed by lots of people as it has been googled much.
  • edited August 19, 2012
    The pull request was reviewed by one of the Zotero developers but is waiting to be reviewed by the other one because the patch modified areas of the code overseen by both. I am not sure if it is on the developer's list of things to do. I don't think that the delay in merging the pull request has affected the timeline of getting the patch into the official release so far. Patches of this nature (not minor typos) get merged into the development version of Zotero and only become part of the official release with the next major update (a version ending in *.0 or *.5). There hasn't been a major update since I submitted the pull request and I don't think one is planned in the immediate future, so it may just be that the developers are focusing on other issues right now. (Obviously, I'd like to see it get merged in though. I'm holding off on working on any other patches until I see what happens with this one).
  • Hi,

    I recently bought a new computer with Windows 7. I started my Zotero DB under Windows XP, where data files were in the C: Drive. Since in W7 all data are in D:, I have lost all links to files. The only way of dealing with this problem I have found so far is renaming the links manually ("show file" - "locate"!) - but with thousands of entries that is hardly realistic. It seems to me that this discussion thread may be relevant to my problem, but I don't feel computer-literate enough to start implementing the suggestions. Is there a simple way of redirecting the links, which would essentially just mean changing "C" to "D" in the paths?
  • edited September 10, 2012
    Hi eagutt,

    I made a function in my Zotero plugin (called Zutilo) that does exactly what you are asking for. You can get the .xpi file for the plugin at this site:

    https://github.com/willsALMANJ/Zutilo

    In the README (also visible on that link), it explains how to install the plugin and how to do what you want (see the "Modify attachment paths" part of the README).

    To use the function (after installing the plugin), you select the parent items of all the attachments whose paths you want changed and then right-click. At the bottom of the context menu that appears, there will be a "Zutilo" submenu and in that menu there will be a "Modify attachment paths" item. There is also a "Show attachment paths" item which you can use to check what you are actually doing to the attachment paths (it is described in the README as well).

    I recommend testing out these functions on just a couple items at first to make sure they work the way you expect them to before modifying your entire collection. It is probably also a good idea to back up your Zotero data first. I have tested and used my plugin with no problem myself, so it should work fine for you, but still I wouldn't want to be responsible for messing anything up. Backing up and restoring your Zotero data is pretty straightforward and is explained here:

    http://www.zotero.org/support/zotero_data
  • Thank you very much, Willshanks! That's a great help - thanks for the good work of all you wizards out there! I ran into a little snag, though, that the Zutilo submenu does not always come up on right-click after selection of the main item, even with the same item (I took 2 screenshots where for the same item once it comes up, once it does not. Can't figure out what the conditions are. If you are interested, I could send those to you - just not sure how to do it over this forum.) Sometimes closing & restarting Zotero helps, but sometimes it does not. Anyway, thanks again!
  • You can upload the screenshot(s) to a free file-sharing site like imgur.com and post the link(s) here.
  • eagutt, does the menu not come up or does it come up greyed out? Right now, I have the menu items set to be disabled if you select attachments or notes because the plugin's functions only work on regular items. I suppose it might be probably better to let the menu items appear when attachments or notes are selected as long as regular items are selected too and then just have the functions ignore the attachments and notes.

    For the "Modify attachment paths" function, you want to select the parent item of the attachment to be modified and not the attachment itself. I did it this way because by default when you first open Zotero all of the item trees in the items pane are closed so none of the attachments are visible or selectable. It's much easier just to select all of the parent items of the attachments from this state (if you want to modify a bunch of attachments) since to select the attachments themselves you would have to expand the tree for each item and then select all of the attachments. If you have opened a bunch of item trees and that is making it annoying not to select attachments and notes, try restarting Firefox and they should all be closed when you reopen Zotero.

    I suppose it would be a good idea to make the "Modify attachment paths" function work on selected attachments in addition to their parent items.
  • While waiting for the implementation of relative path, a very indirect way out for path problem, in Windows environment, is by using Everything (http://www.voidtools.com/) search engine or other similar search tool.
    The steps are as follows:
    1. You find your attachment is broken and cannot be opened directly from inside Zotero. So, remember the file name from Zotero.
    2. Go to Everything, and type partial name of the file.
    3. When found inside Everything, open the file from there.

    This is what I currently use, because I use Zotero from three places with unfortunately different link attachment paths: lab computer, laptop, and portable hdd.
  • Revative path!

    PLEASE COME!
  • As far as I can see, the patch prepared by willshanks will not solve the dual OS issue.

    Any attachment, which is addressed using windows' path separator (i.e. '\'), won't be useful in Linux regardless of the base path modification.

    This is so sad.
  • The current version of the patch makes no reference to path separators and uses the nsIFile (https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIFile) XPCOM component, which should be platform-independent, to handle attachment paths.

    I'd appreciate hearing the results of any testing of the patch by people who would find it useful. I did some testing of it on OSX/Ubuntu/Windows back when I made the most recent changes to the relative path implementation (a few months ago), and the tests I did worked.
  • willshanks,
    does the "Modify attachment paths" function in Zutilo work with networked drives? I have tried without success. I go through the motions, but the link does not change. Perhaps I nee the UNC path?
  • oldenberger, I would think it would work. Right-click on an attachment and choose Zutilo->"Show attachment paths". A popup will appear showing the full path to that attachment. When you do "Modify attachment paths" you should enter the part of that path that you want to change in the first entry box and what you want that path changed to in the second entry box.

    My guess for why it is not working is that sometimes network drives are mapped to multiple names (like both "Z:/" and "/sharename/"). Zutilo won't change a path if what you enter for path to be modified does not match the beginning of the attachment's path. So perhaps you are entering the path as it looks in Windows Explorer and that is different from the form it was saved in in Zotero.
  • willshanks,
    I have had to move my library from a server to a local disk and thus, need to update all my linked files. As displayed by Zutilo's "Show attachment paths" the linked files are at "U:\References\..." - U: is the mapped network drive. I would like to move all links simply to "E:\References\..." so using "Modify attachment paths" I enter "U:\" in the first dialog box and "E:\" in the second. A subsequent call to "Show attachment paths" always comes up with the old path. I have tried the UNC path as well with no love. Any thoughts?

    ps, looking forward to relative paths, thanks.
  • oldenborger, sorry for the trouble. I just tested this on my computer, and I am seeing the same behavior as you. I don't know how I hadn't noticed this before. Perhaps, a recent change to another part of the plugin somehow created this bug. I will try to fix it as soon as I can.

    While I am looking into that, I think you should be able to change the drive letter with the current version of the plugin if in "Modify attachment paths" you enter simply "U" in the first dialog box and simply "E" in the second. Let me know if that works for you.
Sign In or Register to comment.