Score:-3

Nested directories file restore

us flag

I recently took backup of one of my server's drive on AWS using one of the software and now at the time of restoring it i found out it took too long to restore as its having billions of files to restore. I tried to restore it from AWS itself but my problem is backup software created two directories inside my parent directories. I'm looking out some shell script by which i can move file parent direcoties and remove the direcories created by backup software.

Current dir structure :- /opt/folder_to_restore/file_to_restore.pdf$/20211013060615/file_to_restore.pdf

Expected dir strcture :- /opt/folder_to_restore/file_to_restore.pdf

in flag
Nobody is going to write that script for you. Write it, if you encounter problems feel free to post it on [so] or [unix.se]. Here it's rather off topic anyway.
us flag
i figured out the solution for this. simple find command will work for me. Here its find . -type d -iname "*$" -exec bash -c ' loc="$1" ; file="${loc##*\/}" ; mv "$loc/"*"/${file%$}" "${loc%$file}${file%$}"' foo "{}" \;
Score:0
us flag
find . -type d -iname "*$" -exec bash -c ' loc="$1" ; file="${loc##*\/}" ; \
  mv "$loc/"*"/${file%$}" "${loc%$file}${file%$}"' foo "{}" \;

Above find command is working for me.

djdomi avatar
za flag
you are to good to the people ;)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.