I need to rename every subfolder of a specified path.
For example I have a directory structure like this:
project/
/x
/something
/somethingElse
/x
/x.someext
/notXButTheresXInASubfolder
/something
/x
and I need to change it to:
project/
/y
/something
/somethingElse
/y
/y.someext
/thisContainsXIntheNameButIsNotx
/something
/y
I would do this ideally with a bash script, but I have no idea on how to do it...
Answer
DIRS=$(find /path/to/project -type d -name "x" | sort -r)
while read R; do
test -z "$R" && continue;
B=$(dirname "$R")
mv "$R" "$B/y"
done < <(echo -en "$DIRS")
No comments:
Post a Comment