>>>>> "Nick" == Nick Croft <[EMAIL PROTECTED]> writes:

Nick> I keep getting batches of jpegs without the .jpeg extension (or any other
Nick> permutation).

Nick> What area of scripting should I look to in order to add the extension. Is
Nick> sed able to work on filenames in a directory as it doeson words in a file?

Something like this:

file * | sed -n -e '/JPEG/s/^\([^:]*\):.*/mv \1 \1.jpeg/p' | sh


If you may have empty files or PNGs in there too, this'll only touch
the jpegs.  If you have some files that already have an extension,
it's easy enough to change the regexp to toss it away:

file * | sed -n -e '/JPEG/s/^\([^:][^:]*\)\.*[^.]*:.*/mv \1 \1.jpeg/p' | sh

If you're sure that all the files do not have an extension and they
are all jpegs, then the much simpler

for f in *
do
  mv $i $i.jpeg
done

may be used.


-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to