From: bouilhol Date: Mon, 22 Nov 2010 17:35:42 +0000 (+0000) Subject: works even if there are several "/" "\" or "*" in the dicom field and even if there... X-Git-Tag: v1.2.0~297 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=dda180118a4ae07c43473eeccb0be018f8fdbb21;p=clitk.git works even if there are several "/" "\" or "*" in the dicom field and even if there are several fields with the same name --- diff --git a/vv/scripts/dcm_sort_by_field.sh b/vv/scripts/dcm_sort_by_field.sh index 06ffd05..f758ee3 100755 --- a/vv/scripts/dcm_sort_by_field.sh +++ b/vv/scripts/dcm_sort_by_field.sh @@ -17,9 +17,11 @@ do do read i || { wait; break 2; } { - name="$(clitkDicomInfo "$i" | grep "$1" | sed "s/.*\[//;s/.$//;s/ /_/g")" + name="$(clitkDicomInfo "$i" | grep "$1" | head -n 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 - [ -z `echo $name | grep "/"` ] || name=`echo $name | sed 's/\//\_/'` + name=`echo "$name" | sed 's/\//_/g'` + name=`echo "$name" | sed 's/\\\/_/g'` + name=`echo "$name" | sed 's/\*/_/g'` [ -d "sorted/$name" ] || mkdir "sorted/$name" 2>>/dev/null basename=$(basename "$i") cp -l "$i" "sorted/$name/$basename"