Re: Lyx command line question: summarized
In <[EMAIL PROTECTED]>, Angus Leeming <[EMAIL PROTECTED]> typed: > Lars Gullik Bjønnes wrote: > > | The problem is that "for" splits the returned list of files using > > | whitespace... > > > > find foo -name \*.gif -print -exec convert {} `basename {}`.png \; > > then (ha!) > > Thanks. I've just learnt something. > > Don't you have to quote the args passed to convert? Bet you still do. Depends on the shell. { and } are magic to csh and zsh, and need quoting if you're using those. They aren't magic to sh, so they don't need quoting if you're using that. I don't keep bash installed, so I don't know if you need them with bash. As an ex-csh user, I quote them out of habit. But the basename invocation used by lars is wrong. It needs to be $(basename {} .gif).png (I always use $(...); you have to to nest command substitutions, and I find it a bit more readable). If you leave out the .gif, you get the full filename. > Ain't scripting fun ;) Your scripts work much better if you start them with #!/usr/bin/env python :-). http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information.
Re: Lyx command line question: summarized
Lars Gullik Bjønnes wrote: > | The problem is that "for" splits the returned list of files using > | whitespace... > > find foo -name \*.gif -print -exec convert {} `basename {}`.png \; > then (ha!) Thanks. I've just learnt something. Don't you have to quote the args passed to convert? Bet you still do. Ain't scripting fun ;) -- Angus
Re: Lyx command line question: summarized
Angus Leeming <[EMAIL PROTECTED]> writes: | The problem is that "for" splits the returned list of files using | whitespace... find foo -name \*.gif -print -exec convert {} `basename {}`.png \; then (ha!) | > (and you forgot a '$') | | Right :) (And restricted the search to the foo directory rather than the | original .) yeah, but that was not a syntax error (kindo) -- Lgb
Re: Lyx command line question: summarized
[drifting off-topic] In <[EMAIL PROTECTED]>, Angus Leeming <[EMAIL PROTECTED]> typed: > The problem is that "for" splits the returned list of files using > whitespace... > > Perhaps the bigger problem is that you can overrun the internal array size > used by "for" to store the list of returned list of files. "Running out of argument space" always triggers my xargs detector: find foo -name '*.gif' -print0 | xargs -0 -n 1 convert -f gif Which has the advantage that it will work properly on files with newlines in the name. Note that this uses my "open" utility symlinked as "convert", not the "convert" command that comes with Imagemagick. That just happens to do the right thing in this case. http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information.
Re: Lyx command line question: summarized
Lars Gullik Bjønnes wrote: > Angus Leeming writes: > | find foo -name '*.gif' | while read file > | do > | pngfile=`basename "$file" .gif`.png > | convert "$file" "pngfile" > | done > Hmm... I thought thiw was usually written as a for-loop. > for file in `find foo -name \*.gif` ; do > pngfile=`basename "$file" .gif`.png > convert "$file" "$pngfile" > done Won't work when the returned files have spaces in their names. Try out my prescription in the mail you're replying to :) The problem is that "for" splits the returned list of files using whitespace... Perhaps the bigger problem is that you can overrun the internal array size used by "for" to store the list of returned list of files. google on "useless use of cat" or just go here: http://www.ruhr.de/home/smallo/award.html and read the "dangerous backticks" section. > (and you forgot a '$') Right :) (And restricted the search to the foo directory rather than the original .) -- Angus
Re: Lyx command line question: summarized
Angus Leeming <[EMAIL PROTECTED]> writes: | find foo -name '*.gif' | while read file | do | pngfile=`basename "$file" .gif`.png | convert "$file" "pngfile" | done Hmm... I thought thiw was usually written as a for-loop. for file in `find foo -name \*.gif` ; do pngfile=`basename "$file" .gif`.png convert "$file" "$pngfile" done (and you forgot a '$') -- Lgb
RE: Lyx command line question: summarized
Mike Meyer wrote: >> 2) run, before you run pdflatex, something like >> for FILE in `find . -name '*\.gif'`; do convert $FILE `echo $FILE | >> sed 's/\(.*\.\)gif/\1png/'`; done > > basename is safer: > > for file in $(find . -name *.gif) > do > convert $file $(basename $file .gif).png > done Hi, Mike. Hi, Maarten. One step forward (basename) but one step backward too :P You need to quote the *.gif in the find expression: for file in $(find . -name '*.gif') or the shell will perform a glob expansion to those files ending with ".gif" in the current directory. One additional improvement: in general, you should always quote $file or nasty things will happen when the file name contains spaces. Unfortunately, the script above is fundamentally unable to handle files with spaces. To illustrate: $ mkdir foo $ touch 'foo/bar bar.gif' $ touch 'foo/baz baz.gif' $ for file in $(find foo -name '*.gif') do echo "$file" done foo/bar bar.gif foo/baz baz.gif $ find foo -name '*.gif' | while read file do echo "$file" done foo/bar bar.gif foo/baz baz.gif The second version doesn't suffer from buffer overflow problems either. In conclusion, I'd recommend that you use find foo -name '*.gif' | while read file do pngfile=`basename "$file" .gif`.png convert "$file" "pngfile" done (The command `...` is synonymous with $(...).) Ain't scripting a can of worms? :) Regards, Angus
RE: Lyx command line question: summarized
In <[EMAIL PROTECTED]>, Sanders, Maarten (M.J.L.) <[EMAIL PROTECTED]> typed: > 2) run, before you run pdflatex, something like > for FILE in `find . -name '*\.gif'`; do convert $FILE `echo $FILE | sed > 's/\(.*\.\)gif/\1png/'`; done basename is safer: for file in $(find . -name *.gif) do convert $file $(basename $file .gif).png done http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information.
RE: Lyx command line question: summarized
Thank you for all the contribution, Summarized: The latex export command line option works fine for regular latex, latex myfile.tex generates a valid dvi file. If you want to use pdflatex you should either: 1) edit the resulting .tex file and replace \usepackage{graphicx} with \usepackage[dvips]{graphicx} 2) run, before you run pdflatex, something like for FILE in `find . -name '*\.gif'`; do convert $FILE `echo $FILE | sed 's/\(.*\.\)gif/\1png/'`; done 3) Do not use gif's but png's instead Maarten > -Original Message- > From: Georg Baum [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 19, 2005 8:56 AM > To: lyx-users@lists.lyx.org > Subject: Re: Lyx command line question > > > Geoffrey Lloyd wrote: > > > Yes it should but you must note that Export->Pdflatex is > different to > > Export->latex followed by running pdflatex on the file. > > > > In the second case the only Export that Lyx is performing > is Lyx->tex. > > This will not convert any graphics file formats. > > This is true for 1.3.x, but 1.4 converts included graphics > files if needed, and references the converted file in the > .tex file. So the procedure > > lyx --export latex mylyxfile.lyx > pdflatex mylyxfile.tex > > should produce identical results to export->pdflatex from > GUI, with one > exception: > lyx --export latex can not know if the produced .tex file > will be run through pdflatex or latex. It assumes latex, and > this is the problem here: The gif file is converted to eps, > and the .tex file contains '\includegraphics{foo}'. latex > would find foo.eps (which was created), but pdflatex would > find foo.pdf, foo.png or foo.jpg. > > > So I recommend you use png or jpg files in the original dicument. > > This is indeed a workaround until we have a 'pdflatex' export format. > > > Georg > >