Skip to content

Instantly share code, notes, and snippets.

@ted-strauss-K1
Created February 12, 2020 15:15
Show Gist options
  • Save ted-strauss-K1/f51fcf329717a4f07f407ac08be5c1f2 to your computer and use it in GitHub Desktop.
Save ted-strauss-K1/f51fcf329717a4f07f407ac08be5c1f2 to your computer and use it in GitHub Desktop.
sort dicom slices into folders
#!/bin/bash
set -eu
find pTIF0002_20200129_161954623/ -type f | while read f; do
p=$(dcmdump "$f" | awk '/ProtocolName/{print $3;}' | sed -e 's,\],,g' -e 's,\[,,g')
n=$(dcmdump "$f" | awk '/SeriesNumber/{print $3;}' | sed -e 's,\],,g' -e 's,\[,,g')
d="$n-$p"
mkdir -p $d
mv "$f" $d
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment