I have a Windows backup program that is creating a large number of sub-directories with a "$
" at the end. The Linux client for that same backup program is expecting a ":
" at the end of the directory name in order to restore the folders. Some folders have the "$
" and others do not - to do with an internal versioning system.
If I am restoring a file from the windows client to another windows box, the backup program works great. The program is using "$
" in windows because ":
" is invalid in a path.
I am looking for a recursive rename in bash that will step through a path and find all of the folders with a single "$
" char at the end and replace it with a ":
"
My test data is this:
./a$
./b$
./c$
./white space$
./white space$/another test$
./white space$/another test$/a$
./white space$/another test$/b$
./white space$/another test$/x
./white space$/another test$/y
./white space$/test
./white space$/test 2
./white space$/testing$
I have tried :
find . -type d -name "*$"
which gives me a list of the folders that need to be renamed
./a$
./b$
./c$
./white space$
./white space$/another test$
./white space$/another test$/a$
./white space$/another test$/b$
./white space$/testing$
find . -type d -name "*$" | sed 's/$$/\:/'
gives me the end result I am looking for
./a:
./b:
./c:
./white space:
./white space$/another test:
./white space$/another test$/a:
./white space$/another test$/b:
./white space$/testing:
but I can't get it to rename in the same step. Also, I need it to work in reverse order (starting with the deepest match and working back) so that the first rename does not make the rest fail.