DSL Tips and Tricks :: dfm trash can



here's another one.

a trashcan script for dfm.

1. put the script in a folder where to store your trash (probably not in ramdisk). important: the folder can be called anything e.g 'mybin' but the script MUST be called 'trash'.

2. make it executable (e.g chmod 755 trash).

3. navigate to 'mybin' using the dfm '/' icon and create a shortcut link by dragging 'mybin' to the desktop while pressing 'shift'.

files can now be dragged into this 'mybin'

double-click 'mybin' to open it.
double-click 'trash' to delete the files forever.

optionally change the icons for 'mybin' and 'trash' to trashcan.xpm.


(disclaimer: this software deletes. use at your own risk)

Code Sample
#!/bin/lua

alist = {}

lcmd = io.popen ("ls -1a", "r")
if (lcmd) then line=lcmd:read()
while (line) do
 if (line ~= "." and line ~= ".." and line ~= "trash") then
  table.insert (alist,line)
 end
 line=lcmd:read()
end
lcmd:close ()
item = alist[1]
else item = nil
end

i=1
while item ~= nil do
os.execute ("rm -rf "..item)
i=i+1
item = alist[i]
end


edit: just made it smaller

Thanks humpty.  Hope nobody forgets to place the script in a folder (e.g., puts the script on their desktop and clicks it. :)

note: maybe a trash that just deletes a dragged file would be safer
edit: or creates/sends to a trash folder for later deleting??

originally the script would move the files, but i was quite surprised to find that dfm allows you to drop files onto a shortcut!
Quote (humpty @ Jan. 02 2008,17:20)
originally the script would move the files, but i was quite surprised to find that dfm allows you to drop files onto a shortcut!

Shortcuts can act strange.  For example:

You create two files, an app with an ftp path and one with some work:
ftp mypath < someProcedure,files

Link the two files into the desktop apps folder, and make the app drag & drop , so you can drag the work file onto the app.

Although both  are linked  to another location, the list of files in the  work file will have to be in the apps folder to work.  Putting the full path in the  work file doesn't help, either.

Quote
note: maybe a trash that just deletes a dragged file would be safer

That's kind of the idea behind my shredder. Requires intent, zeros out space instead of rm.
http://www.youtube.com/watch?v=F-Kkqi_JrK4

Next Page...
original here.