Skip to content

Commit

Permalink
Add FileRecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed Jul 20, 2023
1 parent f802465 commit 00d5d0a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ AHK_X11 can be used completely without a terminal. You can however if you want u
<details><summary><strong>CLICK TO SEE WHICH COMMANDS ARE IMPLEMENTED AND WHICH ARE MISSING</strong>. Note however that this is not very representative. For example, no `Gui` sub command is included in the listing. For a better overview on what is already done, skim through the <a href="https://phil294.github.io/AHK_X11"><b>FULL DOCUMENTATION HERE</b></a>.</summary>

```diff
DONE ?% (121/220):
DONE ?% (122/220):
+ Else, { ... }, Break, Continue, Return, Exit, GoSub, GoTo, IfEqual, Loop, SetEnv, Sleep, FileCopy,
+ SetTimer, WinActivate, MsgBox, Gui, SendRaw, #Persistent, ExitApp,
+ EnvAdd, EnvSub, EnvMult, EnvDiv, ControlSendRaw, IfWinExist/IfWinNotExist, SetWorkingDir,
Expand All @@ -72,7 +72,7 @@ DONE ?% (121/220):
+ PixelSearch, #Include, InputBox, ClipWait, EnvSet, SetKeyDelay, SetMouseDelay, MouseClickDrag,
+ #NoTrayIcon, TrayTip, Random, Shutdown, RunAs, SoundGet, SoundSet, SoundPlay, Sort,
+ StringTrimLeft, StringTrimRight, WinMinimizeAll, WinMinimizeAllUndo, WinSetTitle, WinWait,
+ WinWaitClose, WinWaitActive, WinWaitNotActive, DriveSpaceFree, FileGetSize
+ WinWaitClose, WinWaitActive, WinWaitNotActive, DriveSpaceFree, FileGetSize, FileRecycle

NEW ?% (9/220): (not part of spec or from a more recent version)
@@ Echo, ahk_x11_print_vars, FileRead, RegExGetPos, RegExReplace, EnvGet, Click @@
Expand All @@ -87,13 +87,13 @@ REMOVED ?% (11/220):
# AutoTrim: It's always Off. It would not differentiate between %a_space% and %some_var%.
# It's possible but needs significant work.

TO DO ?% (75/220): alphabetically
TO DO ?% (74/220): alphabetically
- BlockInput, Control, ControlFocus, ControlGet, ControlGetFocus,
- ControlMove,
- DetectHiddenText, DetectHiddenWindows, Drive, DriveGet,
- FileCopyDir, FileCreateShortcut,
- FileInstall, FileGetAttrib, FileGetShortcut, FileGetTime, FileGetVersion,
- FileMove, FileMoveDir, FileRecycle, FileRecycleEmpty, FileRemoveDir,
- FileMove, FileMoveDir, FileRecycleEmpty, FileRemoveDir,
- FormatTime, GroupActivate, GroupAdd,
- GroupClose, GroupDeactivate, GuiControlGet,
- If var is [not] type,
Expand Down
14 changes: 7 additions & 7 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ <h2>Table of contents </h2>
<a href="#FileRead.htm">FileRead</a>
</li>
<li>
<a class="tbd" href="#FileRecycle.htm">FileRecycle</a>
<a href="#FileRecycle.htm">FileRecycle</a>
</li>
<li>
<a class="tbd" href="#FileRecycleEmpty.htm">FileRecycleEmpty</a>
Expand Down Expand Up @@ -1051,7 +1051,7 @@ <h2 class="calibre18">Tutorial Contents</h2>
<li class="calibre11"><a href="#FileCopy.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileCopy</a>: Copy one or more files. <span class="tbd">Use <a href="#FileCopyDir.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileCopyDir</a> to copy an entire folder. </span></li>
<li class="calibre11"><span class="tbd"><a href="#FileMove.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileMove</a>: Move or rename one or more files. Use <a href="#FileMoveDir.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileMoveDir</a> to move an entire folder. </span></li>
<li class="calibre11"><span class=""><a href="#FileDelete.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileDelete</a>: Delete one or more files. Use <a href="#FileRemoveDir.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileRemoveDir</a> to delete an entire folder. </span></li>
<li class="calibre11"><span class="tbd"><a href="#FileRecycle.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileRecycle</a>: Send one or more files (or an entire folder) to the recycle bin.</span></li>
<li class="calibre11"><span class=""><a href="#FileRecycle.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileRecycle</a>: Send one or more files (or an entire folder) to the recycle bin.</span></li>
<li class="calibre11"><span class=""><a href="#FileSelectFile.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileSelectFile</a> and <a href="#FileSelectFolder.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileSelectFolder</a>: Display a dialog for the user to pick a file or folder.</span></li>
<li class="calibre11"><span class=""><a href="#FileSetAttrib.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileSetAttrib</a> and <a href="#FileSetTime.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileSetTime</a>: Change the attributes or timestamp of one or more files.</span></li>
<li class="calibre11"><span class=""><a href="#IniRead.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">IniRead</a>, <a href="#IniWrite.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">IniWrite</a>, and <a href="#IniDelete.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">IniDelete</a>: Create, access, and maintain standard-format INI files.</span></li>
Expand Down Expand Up @@ -2223,7 +2223,7 @@ <h2 class="calibre9"><span class="calibre23">The "Last Found" Window </span></h2
<td height="16" class="calibre4"> Moves a directory and all sub-directories and files. It can also rename a directory.</td>
</tr>
<tr class="calibre3">
<td height="16" class="tbd calibre4"><a href="#FileRecycle.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileRecycle</a></td>
<td height="16" class="calibre4"><a href="#FileRecycle.htm" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">FileRecycle</a></td>
<td height="16" class="calibre4">Sends a file or directory to the recycle bin, if possible.</td>
</tr>
<tr class="calibre3">
Expand Down Expand Up @@ -4006,9 +4006,9 @@ <h2 class="calibre9"><span class="calibre23">The "Last Found" Window </span></h2
</pre>
</div>
</div>
<div class="calibreMain tbd">
<div class="calibreMain">
<div class="calibreEbookContent">
<a id="FileRecycle.htm" href="#FileRecycle.htm">#</a> <h2 class="calibre17">FileRecycle</h2> [v1.0.09+]
<a id="FileRecycle.htm" href="#FileRecycle.htm">#</a> <h2 class="calibre17">FileRecycle</h2>
<hr size="2" class="calibre24" />
<p class="calibre8">Sends a file or directory to the recycle bin, if possible.</p>
<table cellspacing="5" width="100%" class="calibre28">
Expand All @@ -4025,7 +4025,7 @@ <h2 class="calibre9"><span class="calibre23">The "Last Found" Window </span></h2
<tr class="calibre3">
<td width="15%" class="calibre4">FilePattern</td>
<td width="85%" class="calibre4">
<p class="calibre8">The name of a single file or a wildcard pattern such as C:\Temp\*.tmp. <em class="calibre21">FilePattern </em>is assumed to be in <a href="#Variables.htm__WorkingDir" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">%A_WorkingDir%</a> if an absolute path isn't specified.</p>
<p class="calibre8">The name of a single file or a wildcard pattern such as /tmp/*.tmp. <em class="calibre21">FilePattern </em>is assumed to be in <a href="#Variables.htm__WorkingDir" class="pcalibre3 pcalibre1 pcalibre calibre5 pcalibre2">%A_WorkingDir%</a> if an absolute path isn't specified.</p>
<p class="calibre8">To recycle an entire directory, provide its name without a trailing backslash.</p>
</td>
</tr>
Expand All @@ -4043,7 +4043,7 @@ <h2 class="calibre9"><span class="calibre23">The "Last Found" Window </span></h2
</p>
<p class="calibre8"> </p>
<p class="calibre8"><strong class="calibre14">Example</strong></p>
<p class="calibre8"> FileRecycle, C:\temp files\*.tmp <br class="calibre12" />
<p class="calibre8"> FileRecycle, %A_Home%/temp files/*.tmp <br class="calibre12" />
</p>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions src/cmd/file/file-recycle.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# FileRecycle, FilePattern
class Cmd::File::FileRecycle < Cmd::Base
def self.min_args; 1 end
def self.max_args; 1 end
def self.sets_error_level; true end
def run(thread, args)
begin
Dir.glob(args[0]).each do |src|
Process.new("gio", ["trash", src])
end
"0"
rescue
"1"
end
end
end

0 comments on commit 00d5d0a

Please sign in to comment.