網絡盤/共享盤自建資源回收筒(reg文件解決了win選中項目數量限制)。

 運行 YpanRecycleBin.reg:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\移到Y盤(X盤)資源回收筒\command]
@="\"C:\\Windows\\RecycleBin.bat\" \"%1\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer]
"MultipleInvokePromptMinimum"=dword:00000166

放recyclebin.bat到C:\Windows(跟上面設置的路徑有關):

@echo off
set debugger=0
if %debugger%==1 echo %1
if %1=="" goto myerror1
if %1=="Y:\RecycleBin" goto myerror3


echo 正在檢查文件路徑...
:: ========= 1.文件所在盤符合理性檢查 =========
set mydriver=%~d1
if %debugger%==1 echo 文件(夾)所在盤符:%mydriver%。
if %debugger%==1 pause
if "%mydriver%"=="Y:" goto mycontinue
if "%mydriver%"=="y:" goto mycontinue
if "%mydriver%"=="X:" goto mycontinue
if "%mydriver%"=="x:" goto mycontinue
if "%mydriver%"=="C:" goto myerror2
if "%mydriver%"=="c:" goto myerror2
if "%mydriver%"=="D:" goto myerror2
if "%mydriver%"=="d:" goto myerror2
goto myerror4


:: ========= 2.文件所在路徑合理性檢查 =========
:mycontinue
set filepath=%~dp1
if %debugger%==1 echo 文件(夾)所屬目錄:%filepath%。
if %debugger%==1 pause
set pathof1=%filepath%%~nx1
set pre11str="%pathof1:~3,11%"
if %debugger%==1 echo %pre11str%
set illegelstr="RecycleBin\"
if %debugger%==1 echo %illegelstr%
if %debugger%==1 pause
if %pre11str%==%illegelstr% goto myerror3


echo 正在檢查資源回收筒完整性...
:: ========= 3. 資源回收筒存在合理性檢查 =========
if %debugger%==1 echo  **************
if %debugger%==1 pause
if %debugger%==1 echo nice
if %debugger%==1 pause
if %debugger%==1 echo 文件(夾)路徑:%1。
set myrecyclepath=%~d1\RecycleBin
if %debugger%==1 echo 資源回收筒路徑:%myrecyclepath%。
if %debugger%==1 pause
if  not exist %myrecyclepath%  md %myrecyclepath%
attrib %myrecyclepath%  +h


echo 正在檢查資源回收筒內是否有同名文件...
:: ========= 4. 資源回收筒內無同名文件直接移動 =========
set myfilename=%~nx1
if %debugger%==1 echo 文件/夾名:  %myfilename%
if not exist  "%myrecyclepath%\%myfilename%"  goto mymove

if %debugger%==1 echo 資源回收筒內存在同名文件,正在將其重命名...

echo 發現同名文件,正在將當前文件重命名(附加系統時間信息)...
:: ========= 5. 資源回收筒內有同名文件,先將當前文件重命名附加系統時間信息後移動 =========
set shijian="%date% %time%"
set shijian=%shijian:/=.%
set shijian=%shijian:\=.%
set shijian=%shijian: =_%
set shijian=%shijian::=.%
set shijian=%shijian:<=%
set shijian=%shijian:>=%
set shijian=%shijian:"=%

if %debugger%==1 echo 文件/夾後綴名:%~x1
if %debugger%==1 echo 文件/夾主要名字:%~n1
if %debugger%==1 pause
if %debugger%==1 echo newname=%~n1%shijian%%~x1
set newname=%~n1%shijian%%~x1
if %debugger%==1 echo newname%newname%
if %debugger%==1 pause

if %debugger%==1 echo "%myrecyclepath%\%myfilename%" "%newname%"
if %debugger%==1 pause
ren "%myrecyclepath%\%myfilename%" "%newname%"
if %errorlevel% GTR 0 goto myerror4
if %debugger%==1 echo 重命名成功!


echo 正在移動到資源回收筒...
:: ========= 6. 經過5後,必定不會重名,直接移動 =========
:mymove
if %debugger%==1 echo "%myrecyclepath%\%myfilename%" **************  %1 *****  "%myrecyclepath%"
if  not exist  "%myrecyclepath%\%myfilename%"   move %1  "%myrecyclepath%"
if %errorlevel% GTR 0 goto myerror5
echo 操作成功完成!!!
if %debugger%==1 echo 文件(夾)移到資源回收筒成功!!!
if %debugger%==1 pause
goto:eof


:myerror1
set msg="對不起,發生未知錯誤。"
goto baocuo

:myerror2
set msg="對不起,該功能為X/Y盤專用。"
goto baocuo

:myerror3
set msg="回收站文件不能被再次回收。"
goto baocuo

:myerror4
set msg="無法處理該文件,文件名可能過長。請重命名後再次嘗試。"
goto baocuo

:myerror5
set msg="移到資源回收筒失敗"
goto baocuo

:baocuo
setlocal enabledelayedexpansion
set Vbscript=Msgbox(%msg%,4096,"系統提醒")
for /f "Delims=" %%a in ('MsHta VBScript:Execute("CreateObject(""Scripting.Filesystemobject"").GetStandardStream(1).Write(%Vbscript:"=""%)"^)(Close^)') do Set "MsHtaReturnValue=%%a"
set ReturnValue1=確定

goto:eof

關閉訪問網絡文件的安全彈窗:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值