[OS X TeX] iconv for a set of files

Maarten Sneep maarten.sneep at xs4all.nl
Wed Feb 3 23:18:03 CET 2010


On 3 feb 2010, at 22:41, André Bellaïche wrote:

> Does anybody knows how one can convert a set of TeX files from applemac encoding to latin1?
> 
> I have tried the following command line
> 
> for file in 'ls *.tex'; do iconv -f MAC -t LATIN1 $file > $file.latin1 ; done
> 
> but I get the answer
> 
> -bash: $file.latin1: ambiguous redirect
> 
> If I use the redirection $file > $file, I get the same answer-bash: $file: ambiguous redirect
> 
> What's wrong?

The quotes.

	for file in $(ls *.tex) ; do ...

or 

	for file in `ls *.tex` ; do ...

is what you intended.

Much simpler is:

	for file in *.tex; do iconv -f MAC -t LATIN1 "$file" > "${file%.tex}.latin1.tex" ; done

No need for the ls, *.tex will expand in the shell to the list you wanted. The ${file%.tex}.latin1.tex will first cut off the extension, and then append a new one.

HTMH,

Maarten


More information about the macostex-archives mailing list