Skip to content

Instantly share code, notes, and snippets.

@MattGrayYes
Last active January 28, 2025 12:06
Show Gist options
  • Select an option

  • Save MattGrayYes/f55a67a127992066f9f2170c59b73071 to your computer and use it in GitHub Desktop.

Select an option

Save MattGrayYes/f55a67a127992066f9f2170c59b73071 to your computer and use it in GitHub Desktop.
Rename DICOM file based on Instance Creation Date/Time, and Patient Comments. Handy if you're using an ex-medical X-Ray machine for electronic components, and are using the patient comments metadata field to differentiate between which scan is which.
#!/bin/bash
for i in EI*.dcm;
do comments=`exiftool -s3 -PatientComments $i`
date=`exiftool -s3 -InstanceCreationDate $i | tr -d ":"`
time=`exiftool -s3 -InstanceCreationTime $i | cut -d"." -f1 | tr -d ":"`
name="$date $time I $comments"
cp $i "out/$name.dcm"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment