Using Regex groups in bash

Posted by AlexeyMK on Stack Overflow See other posts from Stack Overflow or by AlexeyMK
Published on 2010-03-11T23:50:29Z Indexed on 2010/03/12 0:57 UTC
Read the original article Hit count: 310

Filed under:
|
|
|
|

Greetings,

I've got a directory with a list of pdfs in it:

file1.pdf, file2.pdf, morestuff.pdf ... etc.

I want to convert these pdfs to pngs, ie

file1.png, file2.png, morestuff.png ... etc.

The basic command is,

convert from to,

But I'm having trouble getting convert to rename to the same file name. The obvious 'I wish it worked this way' is

convert *.pdf *.png

But clearly that doesn't work. My thought process is that I should utilize regular expression grouping here, to say somethink like

convert (*).pdf %1.png

but that clearly isn't the right syntax. I'm wondering what the correct syntax is, and whether there's a better approach (that doesn't require jumping into perl or python) that I'm ignoring.

Thanks!

© Stack Overflow or respective owner

Related posts about regex

Related posts about linux