Dav*_*.ca 21 console cmd batch-file
是否有任何控制台命令"del"从文件夹中删除文件并将它们放入回收站?del命令将删除文件,而不是在回收站中.
一个名为cmdutils的集合中有一个" recycle.exe "命令部分
"Recycle.exe是DEL命令的安全替代品,它将文件发送到回收站而不是删除它们.回收也比DEL更灵活;您可以一次指定多个文件(或使用通配符)"
可在http://www.maddogsw.com/cmdutils上找到
(工具最后更新于2000年5月)
" DeleteXP.exe "用于从Windows(Windows 9x和Windows NT 4.0/2000/XP)中的命令提示符中删除文件.与仅删除文件的标准"DEL"命令不同,Delete XP删除文件并将其发送到回收站.要删除的文件作为参数传递给它.它现在支持/ p并添加两个新选项/ a/d/v.
就像Windows NT/2000/XP中的"del"命令一样,即使在Windows 9x中,Delete XP也支持多个文件名作为参数.
可从http://downloads.easytools.com/Freebies/DeleteXP.zip获取
(工具最后更新时间为2004年9月)
有" recycle.exe "(不同的开发人员来自maddogsw):
C:\>recycle /?
Version 1.11, Copyright (C)2001 Frank P. Westlake
Deletes one or more files by sending them to the Recycle Bin, if possible.
RECYCLE [/PFQ] [/A[[:]attributes]] [[drive:][path]filename
[drive:][path]filename
Specifies the file(s) to delete. Specify multiple files by using wildcards.
/P Prompts for confirmation before deleting each file.
/F Force deleting of read-only files.
/Q Quiet mode, do not ask if ok to delete on global wildcard
/A Selects files to delete based on attributes
attributes R Read-only files
S System files
H Hidden files
A Files ready for archiving
- Prefix meaning not
Run Code Online (Sandbox Code Playgroud)
可在http://web.archive.org/web/20071026113307/http://gearbox.maem.umr.edu/batch/f_w_util/
http://gearbox.maem.umr.edu/batch/f_w_util/
http获取: //gearbox.maem.umr.edu/batch/f_w_util/recycle.zip
(工具最后更新于2001年1月)
BTW如果你想从命令行清空recylce bin"cmdutils"有"bin"命令:
bin /empty /force
Run Code Online (Sandbox Code Playgroud)
好的,这是一个非常古老的线程,但该解决方案有一些其他答案中未解决的属性:
将此单行代码粘贴到名为 recycle.bat 的文件中(以便您可以轻松地从命令行调用它):
@powershell.exe -nologo -noprofile -Command "& {Add-Type -AssemblyName 'Microsoft.VisualBasic'; Get-ChildItem -Path '%~1' | ForEach-Object { if ($_ -is [System.IO.DirectoryInfo]) { [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory($_.FullName,'OnlyErrorDialogs','SendToRecycleBin') } else { [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile($_.FullName,'OnlyErrorDialogs','SendToRecycleBin') } } }"
Run Code Online (Sandbox Code Playgroud)
更新:我发现上述命令存在 Unicode 和包含单引号的文件名的问题。这是整个批处理文件的内容,它也支持递归:
@chcp 65001>NUL
@set RECURSE=
@if /i "%~2" equ "RECURSE" @set RECURSE=-recurse
@if not defined RECURSE @if not exist "%~1" @exit /b
@powershell.exe -nologo -noprofile -Command "& {Add-Type -AssemblyName 'Microsoft.VisualBasic'; Get-ChildItem -Path """%~1""" %RECURSE% | Sort-Object -Property FullName -Desc | ForEach-Object { if ($_ -is [System.IO.DirectoryInfo]) { [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory($_.FullName,'OnlyErrorDialogs','SendToRecycleBin') } else { [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile($_.FullName,'OnlyErrorDialogs','SendToRecycleBin') } } }"
@exit /b
Run Code Online (Sandbox Code Playgroud)
没有外部程序 - deleteJS.bat.它使用Shell.Applicationinvoke动词方法.用法很简单:
call deleteJS.bat c:\someFile.txt
call deleteJS.bat d:\someFolder
Run Code Online (Sandbox Code Playgroud)
如果您安装了节点,则可以添加“ trash ”模块。适用于 OS X、Linux 和 Windows。
$ npm install -g trash
Run Code Online (Sandbox Code Playgroud)
从那里,当您想将文件发送到回收站时,您只需输入:
$ trash file.txt
Run Code Online (Sandbox Code Playgroud)
这是一个第 3 方程序。
注意:我没有尝试过。
| 归档时间: |
|
| 查看次数: |
26917 次 |
| 最近记录: |