I am attempting to name files based on their parent directory names. With a file in ./dir*/dir*/
, I would like to name the file "dir*_dir*"
or "dir*dir*"
(plus some constant appended text and extension but that is not relevant to the question). I have something like:
for file in ./dir*/dir*/*GABA*.dat; do
tag=${file%/*}
tag=${tag} #here, I believe the value of the variable will be "dir*/dir*",
so this is where I was thinking to remove the '/'
tag=$(echo "$tag" | tr '[:upper:]' '[:lower:]')
mv -- "$file" "./GABA/${tag}.dat"
done
I'm not specifically asking for evaluation of the overall code, although that would be welcome also (it runs seemingly properly in another similar context), but particularly how to update my "tag" variable to remove the "/" between dir*/dir*
. Thanks!