p7zip icon indicating copy to clipboard operation
p7zip copied to clipboard

Anyway to delete .7z file after successful extraction?

Open acdcjavier opened this issue 4 years ago • 1 comments

Hello! Exist any way or any command to delete the .7z files after a successful extraction? I need to extract a lot of .7z files that also they are bigger size and the hard disk is almost complete

acdcjavier avatar Jul 01 '21 03:07 acdcjavier

In bash


for f in *.7z; do
    7z x "$f"
    if [ $? -eq 0 ]; then
        rm "$f"
    else
        echo error extracting "$f"
    fi
done

$? is an exit status of program - 0 means success. If 7z returns 0 it means it was successful.

tansy avatar Jul 08 '21 13:07 tansy