Home-dir-relative storage of linked files.
This is an old discussion that has not been active in a long time. Before commenting here, you should strongly consider starting a new discussion instead. If you think the content of this discussion is still relevant, you can link to it from your new discussion.
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.
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.
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
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
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.
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.
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?
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
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.
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.
PLEASE COME!
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.
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.
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?
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.
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.
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.