Hello. I am trying to create a script that recursively looks at my folder structure, and extracts any .7z files that have not already been extracted yet. I know that all .7z files only have a single .txt file in them, and the only .txt file in any directory would be from that .7z file.
I am using 7-zip to extract all of the .7z files.
Here is an example directory structure.
./Folder/
./Folder/Subfolder 1/file A.7z
./Folder/Subfolder 1/file A.txt
./Folder/Subfolder 2/file B.7z
In this example, you can see that within Subfolder 2, the .7z file has not been unzipped, while it has within Subfolder 1. The Folder names and 7z names are variable, along with the depth of the directories.
Here's what I have so far, but I think I'm on the wrong track. So far I have a script that lists all folders that include a .7z file, but I can't figure out the rest. If you have a more efficient solution, I am completely open to it.
find . -type d | while read FOLDER
do
if ls -A "$FOLDER" | grep .7z > /dev/null
then
echo "$FOLDER"
fi
done
Any thoughts??