Deleting files and trash etc
Deleting files and trash etc
When I right click I get a "delete" option to delete a file .
I would like all deleted files to go into the trash bin for say, a day , so that I could recover a file that I had deleted in error.
In fact noting the errors I have seen in Puppy where groups of files just disappear without explanation( probably because of something I have done anyway) it would be prudent to make all deleted files pass through trash anyway with an option to choose when the trash is emptied.
Can this be done at the moment?
I would like all deleted files to go into the trash bin for say, a day , so that I could recover a file that I had deleted in error.
In fact noting the errors I have seen in Puppy where groups of files just disappear without explanation( probably because of something I have done anyway) it would be prudent to make all deleted files pass through trash anyway with an option to choose when the trash is emptied.
Can this be done at the moment?
I have 5.4.2 but I think you mean in Rox filer a trash can comes up next to the "delete" command . When you use this it does not go into trash it is deleted forever..I would like a trash can option on that right click menu at least but it would seem better to me to be able to trash it on all deletes and don't actually lose the file until a time has been reached or the user intentionally removes them to clear up space.
You could try to play with this, but frankly I haven't used it since then and don't know if Darkcity has explored the subject deeper.
Regarding ROX-Filer's Trash - it depends on Puppy version.
Lucid, for instance, has it, but Slacko/Precise haven't.
If you'd like to add Trash to your right-click menu:
1. Safe, but inconvenient method:
Right-click a file/folder -> Customize Menu... -> drag'n'drop Trash icon from desktop into opened dir (create relative symlink).
It has to be repeated for each filetype.
2. Easy, but possibly unsafe method (I haven't had any problems with it, but it's better to make a backup before proceeding):
Save it in /root/my-applications/bin/ as, eg. add_remove_trash.sh and:
a). To add Trash:
b). To remove Trash:
It will automatically create Trash entries for each known and unknown filetype + folders.
EDIT: Small correction in code.
HTH
Greetings!
Regarding ROX-Filer's Trash - it depends on Puppy version.
Lucid, for instance, has it, but Slacko/Precise haven't.
If you'd like to add Trash to your right-click menu:
1. Safe, but inconvenient method:
Right-click a file/folder -> Customize Menu... -> drag'n'drop Trash icon from desktop into opened dir (create relative symlink).
It has to be repeated for each filetype.
2. Easy, but possibly unsafe method (I haven't had any problems with it, but it's better to make a backup before proceeding):
Code: Select all
#! /bin/bash
# Adds/removes Trash to the context menu
OpenWith_PATH="$HOME/.config/rox.sourceforge.net/OpenWith/"
case "$1" in
"add")
# Creates missing folders using 'globs' file contents
for i in `cat /usr/share/mime/globs | grep ":" | cut -f1 -d ':' | tr '/' '_' | uniq`; do
[ ! -d "$OpenWith_PATH"".""$i" ] && mkdir "$OpenWith_PATH"".""$i"
done
mkdir "$OpenWith_PATH"".inode_unknown"
# Creates symlink to the Trash in every folder
for i in `find "$OpenWith_PATH" -maxdepth 1 -type d -iname ".*"`; do
[ ! -L "$i/Trash" ] && ln -s /usr/local/apps/Trash "$i"
done
;;
"remove")
# Removes every symlink to the Trash and removes folder if empty
for i in `find "$OpenWith_PATH" -maxdepth 1 -type d -iname ".*"`; do
rm "$i/Trash"
[ ! "$(ls -A "$i")" ] && rmdir "$i"
done
;;
esac
exit
a). To add Trash:
Code: Select all
add_remove_trash.sh add
Code: Select all
add_remove_trash.sh remove
EDIT: Small correction in code.
HTH
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
Hmm, perhaps something like this:tytower wrote:How would I get trash to emty automatically say in 2 days time ?
Code: Select all
#!/bin/bash
HOW_OLD=2 # in days
while true; do
find /root/.Trash -maxdepth 1 -and -not -name .Trash -ctime +"$HOW_OLD" -print0 | xargs -0 rm -rf
sleep 1h
done
This script should search (every hour) for files/folders older than 2 days in /root/.Trash/ and delete them (if any).
But this one is really barely tested, so please be careful...
(btw, you can replace -ctime with -mmin to use minutes instead of days, but then adjust also the 'sleep' command)
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
Good point - to cover also your's, you can try this instead:
1. Stop the existing script (ps | grep purge_trash and kill its process)
2. Create a directory /root/Moved_From_Trash
3. Replace the appropriate line with:
4. Re-launch the script
This way you can see if files that are supposed to be deleted are the good ones for sure.
Greetings!
1. Stop the existing script (ps | grep purge_trash and kill its process)
2. Create a directory /root/Moved_From_Trash
3. Replace the appropriate line with:
Code: Select all
find /root/.Trash -maxdepth 1 -and -not -name .Trash -ctime +"$HOW_OLD" -print0 | xargs -0 mv -t /root/Moved_From_Trash 2>/dev/null
This way you can see if files that are supposed to be deleted are the good ones for sure.
Greetings!
Last edited by SFR on Fri 18 Jan 2013, 11:06, edited 1 time in total.
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
Great! But you didn't tell me and I forgot to ask, and assumed that you've chosen the 'right-click -> Trash' method, not libtrash. Is that correct?
If so, all's fine. If not, the script simply won't work.
EDIT:
I put -mmin instead of -ctime in the above line of code (leftover from testing).
Corrected now. Please replace it again, or all files from trash will be removed every hour. Sorry for inconvenience.
Greetings!
If so, all's fine. If not, the script simply won't work.
Could be. I'm not an expert in Latin (far from that), but according to different sources: "All that is mine I carry with me" or "I carry all my things with me". But since I carry them, they must be somehow important.Should that be "All of importance I carry with me "?
EDIT:
I put -mmin instead of -ctime in the above line of code (leftover from testing).
Corrected now. Please replace it again, or all files from trash will be removed every hour. Sorry for inconvenience.
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
Yes I left that (-mmin) there to prove it and it worked fine .
I'll have to look a bit closer at this though .
The new directory receives everything that was in the trash can so when opened the choices to open restore ,info ,delete,look inside etc come up . Something resets the trash can lid too when it is emptied so Ill try find that and add a line.
If you look inside you get all the "Appinfo.xml" link and "AppRun" file and "info" file for each trashed file and a Directory for the trashed file itself. I have yet to work out what is happening here but all that seems as it should be I suppose but the size of trash is increased by these as you tresh stuff. About 4.3K is added for each file put in there
Certainly it seems to empty Trash properly though as it should . Ill set up a better test over a longer time and let you know.
Thanks
I'll have to look a bit closer at this though .
The new directory receives everything that was in the trash can so when opened the choices to open restore ,info ,delete,look inside etc come up . Something resets the trash can lid too when it is emptied so Ill try find that and add a line.
If you look inside you get all the "Appinfo.xml" link and "AppRun" file and "info" file for each trashed file and a Directory for the trashed file itself. I have yet to work out what is happening here but all that seems as it should be I suppose but the size of trash is increased by these as you tresh stuff. About 4.3K is added for each file put in there
Certainly it seems to empty Trash properly though as it should . Ill set up a better test over a longer time and let you know.
Thanks