本帖最后由 went 于 2022-4-15 18:52 编辑
test.bat ,ansi编码
放到任意位置,双击添加或删除右键菜单- @echo off
- if not "%~1"=="" if not "%~1"=="REM" goto :handle
- REM 管理员权限
- %1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","REM",,"runas",1)(window.close)&exit
- REM 文件夹右键菜单名称,快捷键,图标
- set "menu_name=一键操作"
- set "menu_hotkey=W"
- set "menu_ico="F:\Picture\Data\WIN32.ico""
- REM 没有则添加,有则删除
- reg delete "HKCR\Directory\shell\%menu_name%" /f 2>nul && (
- echo 删除右键菜单 %menu_name% 成功
- ) || (
- reg add "HKCR\Directory\shell\%menu_name%" /ve /d "%menu_name%(&%menu_hotkey%)"
- reg add "HKCR\Directory\shell\%menu_name%" /v "icon" /d "%menu_ico%"
- reg add "HKCR\Directory\shell\%menu_name%\command" /ve /d "\"%~0\" \"%%1\"" /f
- echo 添加右键菜单 %menu_name% 成功
- )
- pause&exit
- :handle
- if not exist "%~1\" echo ( 文件夹路径无效 & pause&exit )
- cd /d "%~dp1"
- REM 提取选中文件夹下的所有文件移动到上层目录
- for /f "delims=" %%a in ('dir /a-d /b /s ') do move "%%~a" . 2>nul
- REM 删除当前文件夹下要删除的子文件夹名称
- for /f "delims=" %%i in ('dir /b /ad ^| findstr "子文件名称"') do rd /s /q "%%i"
- REM 删除指定名文件
- for /f "delims=" %%i in ('dir /b /s /a-d "CDImage.wav" "CDImage.cue"') do del /f /q "%%i"
- REM 删除当前空文件夹
- for /f "delims=" %%a in ('dir/s/ad/b^|sort /r') do (echo,rd "%%a" & rd "%%a")
- pause&exit
复制代码
|