]> Creatis software - clitk.git/commitdiff
don't crash if ther is a "/" in the dicom field
authorbouilhol <bouilhol>
Tue, 9 Nov 2010 13:52:35 +0000 (13:52 +0000)
committerbouilhol <bouilhol>
Tue, 9 Nov 2010 13:52:35 +0000 (13:52 +0000)
vv/scripts/dcm_sort_by_field.sh

index 3ce4ec964081a781759738775667f60479b977c0..06ffd05d1ae90c7918b20061de8bb165ea991a56 100755 (executable)
@@ -19,7 +19,8 @@ do
         {
             name="$(clitkDicomInfo "$i" | grep "$1" | sed "s/.*\[//;s/.$//;s/ /_/g")"
             [ -z "$name" ] && echo "Warning: key not found in file $i" 1>&2 && exit 1 #don't do anything if dicom key not found
-            [ -d "sorted/$name" ] || mkdir "sorted/$name" 2>>/dev/null
+            [ -z `echo $name | grep "/"` ] || name=`echo $name | sed 's/\//\_/'`
+           [ -d "sorted/$name" ] || mkdir "sorted/$name" 2>>/dev/null
             basename=$(basename "$i")
             cp -l "$i" "sorted/$name/$basename"
         }&