0

I would be really, extremly happy if someone could help me with this problem. I want to be able to extract one or more files with only one or more parts and then deleting the archive(s). It doesn't matter if this would work for 7z or unrar.

So far I found this command and parameters and it is really working- but one thing doesn't work- the script want's to extract the second (and third, and so on) part too! But the script should only extract the first part (or only) part and then delete it (or also the other parts)

for example:

banana.part1.rar banana.part2.rar

this script is working so far very good:

find . -name '*.rar' -execdir unrar x {} \; -exec rm {} \;

but the script tries also to unrar .part2.rar and the other parts :( Thats because of this wildcard ... and it is not possible to say '*.part1.rar" because some archives could also have only "banana.rar". Maybe there should be a -not -name thing with not .part2 and higher or .part02 and higher :/

So my idea is a command/script that extracts recursively all .rar/7z archives with maybe parts- and delete after that all .rar/.7z files.

(Now, after an hour I scripted this^^) :

find . -name '*.001' -execdir 7z x {} \; && find . -name "*7z*" -type f -delete

if there won't be a better solution from someone else, I'll post this as solution. It works only with 7z, because I can set the parameter everytime to create the files in 2048MiB Parts- so 7z will always create .001 endings. Even if the file is smaller than 2048MiB, so every file will be ending with .001. So find will find at the beginning all .7z archives and extract them and THEN it will scan the directory recursively to delete every 7z file- and now it doesn't matter if .001 or .069 :)

1 Answer 1

0
find . -name '*.001' -execdir 7z x {} \; && find . -name "*7z*" -type f -delete

This is the best solution I've got so far, as mentioned in the main post.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .