shred_file

Nautilus Scripts

Source:

Score 54%
Description:

------------------------------------------------------------------------------
***CAUTION***
Do NOT use on device files like /dev/hda.
If you need to shred these files, refer to the shred man pages.
***CAUTION***
Use of this script on a file will make recovery impossible,
even with the more expensive file recovery solutions.

This script will shred the input file, after confirmation.
You will also be notified, when shredding is complete. (Should this be
removed?)

Depends
-------
*Obviously you need to have the shred utility installed and in your $PATH.
Since there are some misconceptions/worries about the shred utility regarding ext3, I will put it simple:
If your /etc/fstab file contains an entry for an ext3 partition, and that entry uses 'data=journal',
then the shredded file can still be recovered. If your /etc/fstab file contains an entry for an ext3
partition, and that entry uses 'data=ordered' or 'data=writeback', then your file is gone for good.

*This script also makes use of zenity (http://freshmeat.net/projects/zenity)
This also works well as a Nautilus Action. See the included screenshot for my example configuration.

See README for more info
Last changelog:

6 years ago

1.0:
20111205
Complete rewrite by warserv. Wanna take this over? Email me.
This version will display a confirmation dialog; it can handle file paths with spaces in them; it catches and displays stderr from shred; and it displays a zenity progress bar.

0.2:
20100402
Updated to support shredding multiple files. Thanks jbom.

0.1:
20070907 Script release

warsev

7 years ago

This version will display a confirmation dialog; it can handle file paths with spaces in them; it catches and displays stderr from shred; and it displays a zenity progress bar. Use at your own risk, of course.
[code]
#!/usr/bin/env bash
nfiles="$#"
files=""
for file in "$@" ; do
if [ ${#files} -gt 0 ] ; then files="$files\n"; fi
files="$files$file"
done
zenity --question --title="shred these $nfiles files - REALLY??" --text="$files"
if [ "$?" = 1 ] ; then
exit $?
else
nfile=0
(for file in "$@" ; do
echo "# shredding $file..."
shredout=$(shred -u -z -n 1 "$file" 2>&1)
rc=$?
if [ $rc -ne 0 ] ; then
echo "100"
zenity --error --title="No break for you today" --text="$shredout"
exit $rc
else
let nfile++
echo $((nfile * 100 / nfiles))
fi
done ) | zenity --progress --title="Wiping files..." --auto-close \
--percentage=0 --text="starting..." --no-cancel
fi
exit 0
[/code]

Report

warsev

7 years ago

Small revision to display just file basenames, not full paths.
[code]
#!/usr/bin/env bash
nfiles="$#"
files=""
for file in "$@" ; do
if [ ${#files} -gt 0 ] ; then files="$files\n"; fi
files=$files$(basename "$file")
done
zenity --question --title="shred these $nfiles files - REALLY??" --text="$files"
if [ "$?" = 1 ] ; then
exit $?
else
nfile=0
(for file in "$@" ; do
echo \# shredding $(basename "$file")...
shredout=$(shred -u -z -n 1 "$file" 2>&1)
rc=$?
if [ $rc -ne 0 ] ; then
echo "100"
zenity --error --title="No break for you today" --text="$shredout"
exit $rc
else
let nfile++
echo $((nfile * 100 / nfiles))
fi
done ) | zenity --progress --title="Wiping files..." --auto-close \
--percentage=0 --text="starting..." --no-cancel
fi
exit 0
[/code]

Report

C

sp00k113

6 years ago

Thanks. I have updated to reflect these changes.
I don't really want to maintain this anymore. Anyone want it?

Report

D4v3

7 years ago

Thank you very much for this!

Report

hellboy17291

8 years ago

hi...was wonderin if there r any probs with the script on ext 4...please let me know..thanx in advance...

Report

C

sp00k113

8 years ago

Going to try this out...

Report

luciferax

8 years ago

Hi, thanks for it. Recently changed to gnome (ubuntu) and tried to implement this into nautilus. it works pretty well for single file... how can i get around -or do you have a fix for- for selecting multiple files at once and --> "shred". or did i made a mistake ? i tried to change action settings while configuring nautilus, and selected 'let it be appear when multiple files are selected', it appears, but then when i select 'shred', it shreds only the first file in selection and stops. any idea how i can get around this ?
Thanks in advance.

Report

jbom

8 years ago

Hi,
This is the first response I have made on any forum and the first time I have put any code up (glad to do it finally) so excuse me if I don't do this right.
Thanks for the original script, it opened my eyes.
I modified it slightly so it handles multiple files and sets the number of passes to 1 (I was using it on a sd card). I think 1 pass for most media is good enough for normal people, you can change it by modifying or removing the -n 1 argument to shred. Seems to work ok.

files="$@"
zenity --question --title="Shred" --text="Are you sure you wish to shred $# files: $files?"
if [ "$?" = 1 ] ; then
exit $?
else
shred -u -z -n 1 $files
zenity --info --text="$# files shredded: $files."
fi

Report

C

sp00k113

8 years ago

Awesome thanks, updating.

Report

OmegaTree

10 years ago

Nice idea...I've been looking for a simple little script to destroy files. The fact that it can be used in the nautilus actions is pretty cool too.

Unfortunately I can't get it to work. I set up up, rightclick, shred, and it says "are you sure?", and I click yes. It says its done and accomplished but the file is still there. However I'm using XFS (whoot!) but I guess that's causing trouble. I have zenity but it still ain't working. I hope this has been any bit helpful and I hope that it can be made to work for all FS's.

Report

Rafterman

10 years ago

Try running the script via the command line: $HOME/.gnome2/nautilus-scripts/shred_file somefile_to_shred

That should help shed some light as to what's going on. You should have zenity though if you say you got a dialog box after starting the script. Do "whereis zenity" to find out for sure.

Report

C

sp00k113

10 years ago

if running the script from the cli works OK, it would have to be your Nautilus action. I included a screenshot in the tarball that is not posted here, showing an example (my) nautilus action setup for reference. If you get errors on the cli, post here and I will see what I can do for you.

Report

OmegaTree

10 years ago

thanks man...it was the %M that was missing. After that, it worked fine. Not sure if it'll work in the long run because of me running XFS but the first step is done...

Report

6 years ago

1.0:
20111205
Complete rewrite by warserv. Wanna take this over? Email me.
This version will display a confirmation dialog; it can handle file paths with spaces in them; it catches and displays stderr from shred; and it displays a zenity progress bar.

0.2:
20100402
Updated to support shredding multiple files. Thanks jbom.

0.1:
20070907 Script release

product-maker D4v3 Jan 24 2011

product-maker 11 13

File (click to download) Version Description Packagetype Downloads Date Filesize DL OCS-Install
Details
license
version
1
updated Dec 05 2011
added Sep 20 2007
downloads today
0
page views today 1
System Tags addon