#!/bin/bash


NewSimu=$( cat param.txt)
OldSimu=${NewSimu}.BP

for FullFile in $( find ${OldSimu} -type f -print )
do
    FileName=$( basename ${FullFile} | sed "s=/$=="  | sed "s=^/=="  )
    ShortDir=$( dirname  ${FullFile} | sed "s=${OldSimu}==" | sed "s=/$=="  | sed "s=^/=="  )

    echo ${FullFile} ${NewSimu}/${ShortDir}/${FileName}
    mkdir -p ${NewSimu}/${ShortDir}
    mv   ${FullFile} ${NewSimu}/${ShortDir}/${FileName}
done


find ${OldSimu} -type d -empty | sort -r | xargs -r rmdir --ignore-fail-on-non-empty -p


# for FullDir in $( find ${OldSimu} -type d -empty -print )
# do
#     echo ${FullDir}
#     rmdir ${FullDir}
# done


