Thursday, May 9, 2024
 Popular · Latest · Hot · Upcoming
14
rated 0 times [  14] [ 0]  / answers: 1 / hits: 95235  / 3 Years ago, tue, may 18, 2021, 11:59:06

Is there a way (preferrable via GUI, but may be via command line) to extract a zip file and delete the zip after extracted, all in a single command?



(I remember I saw someone doing something like this in the command line one day)


More From » zip

 Answers
2

For a GUI I'd say the easiest way is a nautilus script. The main line of which would be:



unzip "$item" && trash "$item"


It works in bash/dash just as easy. In nautilus the whole thing would look like this:



unzip delete nautilus script



#!/bin/bash
# Nautilus script to unzip and then remove a zip archive.
# Nautilus script usually go in "$HOME/.gnome2/nautilus-scripts"

IFS='
'
for item in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS; do
if [ -n "$(file -b "$item" | grep -o 'Zip')" ]; then
unzip "$item" && trash "$item"
# use trash instead of rm to move them to trash
# (trash-cli package installed)
fi
done

[#43826] Wednesday, May 19, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
amacal

Total Points: 457
Total Questions: 102
Total Answers: 116

Location: Thailand
Member since Thu, Apr 22, 2021
3 Years ago
;