This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using exec in find, awk? xargs?

 
Pat Farrell
Rancher
Posts: 4660
5
Linux Mac OS X VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to run the ImageMagick "convert" program on a bunch of files. The find command is the obvios way to find the files.

find . -name "*.tif" -print
works perfectly.

What I want to do is run the convert program, something like

convert foo.tif foo.png

So I want to get the name and add a new extension, .png

Any help or even hints will be greatly appreciated.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11833
181
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you know that your files will all end in tiff, then you could just use sed:


(Untested, but it should work, unless you have spaces in your filenames, in which case that is a separate problem)
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17633
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're truly evilly-minded, use the "xargs" utility and do it as a one-liner. I'm not up to actually attempting this on the spot, but if would be something vaguely resembling this, I think:


The trickiest part is probably going to be the filename subsitution on the xargs command, but I believe that using double-quotes around the braces is the way it works.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic