On 10/02/2009 09:33 AM, Christopher Reeve wrote:
Thanks Richard
I'll look into lypak.py. Actually I use Linux, Mac and Windows machines. I
wrote my thesis on a Mac, made some corrections on a Windows machine, but
now mostly use my eee pc which has eeebuntu on it. I didn't know about the
tar options to include original files. That indeed might be my solution for
the future and that would enable me to more easily share my documents
without creating duplicates of my graphics. I wonder if rsync can do
something similar...
Yes: the -L option tells rsync to copy links as the referred file/dir. I
use this when uploading my websites to their servers. Many of the actual
images and files live outside /var/www/html/ and are linked. When I
upload, I want the real file to go.
I think the only problem with creating a soft link to every image is that it
would be time consuming and I would have to look at where it points to via a
terminal as opposed to just copying and pasting the path from within LyX if
I wanted to know the images real location.
The "bundled" format I once worked on had some options kind of like what
you want. But it got abandoned amidst the arguments surrounding that
format. Still, creating the symlinks can't be that time consuming. One
way to do it is to keep two instances of your file manager open: One in
the graphics/ subdirectory, and one to find the images you want. When
you find it, you can copy it as a link to the subdirectory. Back in LyX,
you now don't have to hunt for the file. It'll always be right there.
As far as the thesis itself goes, it should be pretty simple to write a
little script that extracts all the paths to images: Search for lines
like "\begin_inset Graphics", then grab the filename from the next line
you see that looks like:
filename \path\to\image.ext
E.g. in Perl:
$gdir = "/path/to/graphics/dir";
$lyxfile = "/path/to/file.lyx";
open INFILE, $lyxfile;
$flag = 0;
while (<INFILE>) {
if (!$flag && m/\\begin_inset Graphics/) { $flag = 1; next; }
if (m/filename \s*(.*)) {
$old = chomp($1); # kill trailing newline
$new = $old;
$new =~ s{.*/}{}; # kill up to final slash
symlink($old, "$gdir/$new");
$flag = 0;
}
}
Not perfect, and not tested, but simple enough.
rh