#!/bin/sh # filename: mklinks2 # # UTIL SCRIPT: 29-Apr-2002 (eNlf v0.2) # # purpose : create links in current working dir # # argument: dir with images # # notes : - freaks out on names containing spaces # # - how to addapt to your naming convention? # # To make this a little easier for scripting illiterates, we 've # included a more complex awk-line in the linkname creation. # All entries involved are shown on a line by line basis, in a human # readable name, between the two { and } brackets. # # All what needs to be done is simply removing the entire line # of unwanted entries, located between those curly brackets. # # Removing too much will result in a broken script syntax. # # check on argument if [ "$1" = "" ]; then echo "usage: mklinks " exit 1 fi # get list of all files FILES="$1/*" # make links to each file for FILE in $FILES do # create link name - remove unwanted entries (lines) between curly brackets LINKNAME=`medcon -f $FILE --echo-alias-name | awk -F\+ '{ print \ $patient_name \ "+" \ $study_name \ "+" \ $study_date \ "+" \ $study_time \ "+" \ $series_number \ "+" \ $acquisition_number \ "+" \ $image_number \ }' patient_name=1 study_name=2 study_date=3 study_time=4 \ series_number=5 acquisition_number=6 image_number=7` if [ $? -eq 0 ]; then ln -s $FILE $LINKNAME else echo "warning: no link created for $FILE" fi done