My aim:
mv /*/**/word/* ../../..
but if anything exists in ../../..
then try to mv it as filename_2, if error then try filename_3, etc
------------------------------------------------------------------------------
I've ended up with:
#!/bin/bash
let i=2;
for file in /cygdrive/c/cygwin/1111/*/members/*/*; do
mv "$file" "${file}/../../.."
if [ "$?" = "1" ]; then
while [[ -d "${file%/../..}_$i" ]]; do
let i++
done
name2="${file}_$i"
mv "${file}" "${name2}"; mv "${name2}" "${name2}/../../.."
fi
let i=2
done
----------------------------------------------------------------------------------------
Well, it does what I want,
BUT needs to be run several times in order to mv all the dirs needed,
AND, what I get at the end is:
dirname
dirname_2
dirname_2_2