I have a lot of rar files
- Folder/
--- Spain.rar
--- Germany.rar
--- Italy.rar
All the files contains no root folder so it's just files.
What I want to achieve when extracting is this structure:
- Folder/
-- Spain/
---- Spain_file1.txt
---- Spain_file2.txt
-- Germany/
---- Germany_file1.txt
---- Germany_file2.txt
-- Italy/
---- Italy_file1.txt
---- Italy_file2.txt
So that a folder with the name of the archive is created and the archive is extracted to it.
I found this bash example in another thread but it's not working for me, it's trying to create one folder with all the files as name.
#!/bin/bash
for archive in "$(find . -name '*.rar')"; do
destination="${archive%.rar}"
if [ ! -d "$destination" ] ; then mkdir "$destination"; fi
unrar e "$archive" "$destination"
done
Any ideas how I can do this?