Last active
July 9, 2016 20:57
-
-
Save alxndrkalinin/bce0d3726eaff0a8d82283b905e4a69c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# call: "renameOffFilesByLst.sh norm/157" | |
runnum=${1##*/} | |
class=${1%/*} | |
destdir="${class}_off_named/$runnum" | |
listfile="0000${runnum}_c2.lst" | |
echo $listfile | |
liststring=$(cat $listfile |tr "\n" " ") | |
list=($liststring) | |
listLen=${#list[@]} | |
filesnum=$(ls $1 | wc -l) | |
# check if number of files in directory matches number of lines in .lst file | |
if [ "$listLen" -eq "$filesnum" ]; then | |
mkdir $destdir | |
shapesubdir="/ShapeTranslator_1.ShapeOutputDirectory-" | |
count=1 | |
for nucleolus in "${list[@]}"; do | |
nucleolusname=${nucleolus%.nii*} | |
leadingzeros="$(ls $1 | wc -l)" | |
leadingzeros="$(echo $leadingzeros)" | |
leadingzerosnum="${#leadingzeros}" | |
idxformat="%0${leadingzerosnum}d" | |
printf -v idx $idxformat $count | |
currdir=$1$shapesubdir$idx | |
filename="/182_QEM_SubDiv.off" | |
target=$currdir$filename | |
dest="$destdir/$nucleolusname.off" | |
cp $target $dest | |
((count++)) | |
done; | |
fi < $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment