Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recycle File
#12
Code: (Select All)


Screen _NewImage(800, 600, 32)

Open "MyFile.txt" For Output As #1
Print #1, "Test:" + Date$ + " " + Time$
Close
Print "File created called MyFile.txt"

Recycle "MyFile.txt"
Print "MyFile.txt should now be recycled and in the Recycle Bin, instead of just erased permanently."
Print "Check your recycle bin to see if it exists there and contains a simple message of 'Test'."
End

Sub Recycle (file$)
If _FileExists(file$) Then
$If WIN Then
ps$ = "powershell -NoLogo -NoProfile -Command "
ps$ = ps$ + Chr$(34) + "Add-Type -AssemblyName Microsoft.VisualBasic; "
ps$ = ps$ + "[Microsoft.VisualBasic.FileIO.FileSystem]:eleteFile('"
ps$ = ps$ + file$
ps$ = ps$ + "','OnlyErrorDialogs','SendToRecycleBin')" + Chr$(34)
Shell _Hide ps$
$ElseIf MAC Then
' Build an osascript command that tells Finder to delete the POSIX file (move to Trash)
' Use single quotes around the whole -e argument in the shell, and escape inner double quotes for AppleScript.
cmd$ = "osascript -e " + Chr$(34) + _
"tell application " + Chr$(34) + "Finder" + Chr$(34) + _
" to delete POSIX file " + Chr$(34) + file$ + Chr$(34) + Chr$(34)
Shell cmd$
$Else
'Assume Linux-like environment with gio available
Shell _Hide "gio trash " + Chr$(34) + file$ + Chr$(34)
$End If
End If
End Sub

One last test. This is after pestering AI to sort out the formatting issue. It claims this will work. LOL

Tony suggests changing that delete to move and giving it a test if this doesn't work. @NakedApe mind giving both variations a try and see what we break?
Reply


Messages In This Thread
Recycle File - by SMcNeill - 02-27-2026, 10:20 PM
RE: Recycle File - by SMcNeill - 02-27-2026, 10:31 PM
RE: Recycle File - by SMcNeill - 02-27-2026, 11:16 PM
RE: Recycle File - by NakedApe - 02-28-2026, 12:36 AM
RE: Recycle File - by ahenry3068 - 02-28-2026, 01:12 AM
RE: Recycle File - by NakedApe - 02-28-2026, 01:03 AM
RE: Recycle File - by ahenry3068 - 02-28-2026, 01:06 AM
RE: Recycle File - by SMcNeill - 02-28-2026, 01:16 AM
RE: Recycle File - by NakedApe - 02-28-2026, 01:16 AM
RE: Recycle File - by ahenry3068 - 02-28-2026, 01:34 AM
RE: Recycle File - by ahenry3068 - 02-28-2026, 01:42 AM
RE: Recycle File - by SMcNeill - 02-28-2026, 01:53 AM
RE: Recycle File - by SMcNeill - 02-28-2026, 01:24 AM
RE: Recycle File - by NakedApe - 02-28-2026, 01:24 AM
RE: Recycle File - by SMcNeill - 02-28-2026, 01:33 AM
RE: Recycle File - by NakedApe - 02-28-2026, 01:33 AM
RE: Recycle File - by NakedApe - 02-28-2026, 01:39 AM
RE: Recycle File - by NakedApe - 02-28-2026, 01:43 AM
RE: Recycle File - by SMcNeill - 02-28-2026, 01:43 AM
RE: Recycle File - by NakedApe - 02-28-2026, 01:45 AM
RE: Recycle File - by SMcNeill - 02-28-2026, 01:50 AM
RE: Recycle File - by SMcNeill - 02-28-2026, 02:05 AM
RE: Recycle File - by NakedApe - 02-28-2026, 02:10 AM
RE: Recycle File - by SMcNeill - 02-28-2026, 02:14 AM
RE: Recycle File - by Pete - 02-28-2026, 04:09 AM
RE: Recycle File - by justsomeguy - 02-28-2026, 05:22 PM
RE: Recycle File - by SMcNeill - 02-28-2026, 05:35 PM
RE: Recycle File - by justsomeguy - 02-28-2026, 05:55 PM
RE: Recycle File - by SMcNeill - 02-28-2026, 07:07 PM
RE: Recycle File - by NakedApe - 02-28-2026, 07:42 PM
RE: Recycle File - by SMcNeill - 02-28-2026, 07:58 PM
RE: Recycle File - by SMcNeill - 02-28-2026, 08:12 PM
RE: Recycle File - by NakedApe - 02-28-2026, 10:23 PM
RE: Recycle File - by SMcNeill - 03-01-2026, 01:12 AM
RE: Recycle File - by SMcNeill - 03-01-2026, 02:36 AM
RE: Recycle File - by justsomeguy - 03-01-2026, 03:35 AM
RE: Recycle File - by SMcNeill - 03-01-2026, 04:26 AM
RE: Recycle File - by SMcNeill - 03-01-2026, 04:34 AM
RE: Recycle File - by NakedApe - 03-01-2026, 06:12 AM
RE: Recycle File - by SMcNeill - 03-01-2026, 07:14 AM
RE: Recycle File - by NakedApe - 03-01-2026, 02:34 PM
RE: Recycle File - by NakedApe - 03-01-2026, 03:13 PM
RE: Recycle File - by SMcNeill - 03-01-2026, 03:26 PM
RE: Recycle File - by NakedApe - 03-01-2026, 04:39 PM

Forum Jump:


Users browsing this thread: