Using properties to mass rename images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Frogger
Posts: 3
Joined: 2016-10-13T03:08:53-07:00
Authentication code: 1151

Using properties to mass rename images

Post by Frogger »

Hi,

I have got a ton of dicom files that I want to mass rename using their properties tags.

My question is, what is the syntax for taking a property tag(such as dcm:SeriesNumber) for every image and using it to rename the images in the directory?

I'm guessing it involves breaking it down to the relevant tag using -identify -verbose and then somehow passing that string over to the filename property?

Really would appreciate the help(using win10 command line).
Frogger
Posts: 3
Joined: 2016-10-13T03:08:53-07:00
Authentication code: 1151

Re: Using properties to mass rename images

Post by Frogger »

Almost got it.

Code: Select all

convert *.dcm -set filename:f "%[dcm:SeriesNumber]%[dcm:AcquisitionNumber]" "%[filename:f].jpg"
How do I set an underscore in-between dcm:SeriesNumber and dcm:AcquistionNumber?
Frogger
Posts: 3
Joined: 2016-10-13T03:08:53-07:00
Authentication code: 1151

Re: Using properties to mass rename images

Post by Frogger »

Aaand got it.

Code: Select all

convert *.dcm -set filename:f "%[dcm:SeriesNumber]"_"%[dcm:AcquisitionNumber]" "%[filename:f].jpg"
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Using properties to mass rename images

Post by GeeMack »

Frogger wrote:How do I set an underscore in-between dcm:SeriesNumber and dcm:AcquistionNumber?
You shouldn't even need to use two sets of quote marks. I haven't tried it, but I'd make a pretty confident guess that this will work...

Code: Select all

convert *.dcm -set filename:f "%[dcm:SeriesNumber]_%[dcm:AcquisitionNumber]" "%[filename:f].jpg"
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using properties to mass rename images

Post by snibgo »

If you don't have spaces in the sub-fields, you probably don't needs quotes at all.
snibgo's IM pages: im.snibgo.com
Post Reply