1.电脑开机一键启动多个应用
注意:需要修改代码中应用的路径
@echo off
:: ============================================
:: 一键启动程序(自动关闭窗口版)
:: 功能:启动指定程序,已运行则跳过
:: ============================================
:: 基本配置
title Program Launcher
chcp 65001 >nul
color 0a
goto main
:Launch
if "%~1"=="" (
echo [X] 错误:未提供EXE文件名
goto :eof
)
if "%~3"=="" (
echo [X] 错误:未提供程序路径
goto :eof
)
if not exist "%~3" (
echo [X] 错误:路径不存在: %~3
goto :eof
)
tasklist /NH /FI "IMAGENAME eq %~1" 2>nul | find /i "%~1" >nul
if %errorlevel% equ 0 (
echo [√] %~2 已在运行
) else (
echo [ ^> ] 正在启动 %~2...
start "" /B /D "%~dp3" "%~3"
timeout /t 2 /nobreak >nul
)
goto :eof
:main
call :Launch "idea64.exe" "IDEA" "E:\soft\IntelliJ IDEA 2023.2\bin\idea64.exe"
call :Launch "dbeaver.exe" "DBeaver" "E:\soft\DBeaver\dbeaver.exe"
call :Launch "chrome.exe" "Chrome" "C:\Program Files\Google\Chrome\Application\chrome.exe"
call :Launch "notepad++.exe" "Notepad++" "E:\soft\binNotepad++\notepad++.exe"
for %%A in ("C:\Program Files (x86)\Feishu\Feishu.exe") do (
set "feishu_path=%%~sA"
)
call :Launch "Feishu.exe" "飞书" "%feishu_path%"
echo.
echo =====================
echo 所有程序已处理完毕!
timeout /t 2 >nul
exit
2.一键删除某个目录下所有的target、.git、.idea文件夹*.iml文件
@echo off
setlocal enabledelayedexpansion
:: 设置要搜索的根目录
set "root_dir=E:\code1"
echo 当前工作目录: %cd%
echo 检查的目录: %root_dir%
:: 检查目录是否存在
if not exist "%root_dir%" (
echo 错误: 目录 "%root_dir%" 不存在
pause
exit /b
)
echo 正在扫描 %root_dir% 下的 target、.git、.idea 文件夹和 *.iml 文件...
echo.
:: 使用 PowerShell 查找隐藏文件夹
set "found_folders=0"
for /f "delims=" %%f in ('
powershell -NoProfile -Command "Get-ChildItem -Path '%root_dir%' -Directory -Force -Include '.git', '.idea', 'target' -Recurse | Select-Object -ExpandProperty FullName"
') do (
set "folder=%%f"
call :process_folder
)
:: 递归搜索子目录中的 target、.git、.idea 文件夹(但不递归它们的子文件夹)
call :search_subfolders "%root_dir%"
:: 删除所有 .iml 文件(递归搜索)
set "found_files=0"
echo 正在搜索 .iml 文件...
for /f "delims=" %%f in ('dir /s /b "%root_dir%\*.iml" 2^>nul') do (
set "file=%%f"
call :process_file
)
echo.
echo 扫描完成:
echo 找到 !found_folders! 个文件夹
echo 找到 !found_files! 个 .iml 文件
pause
exit /b
:: 处理找到的文件夹(不递归子文件夹)
:process_folder
echo 找到文件夹: !folder!
set /a found_folders+=1
rd /s /q "!folder!" >nul 2>&1
goto :eof
:: 处理找到的文件
:process_file
echo 找到文件: !file!
set /a found_files+=1
del /f /q "!file!" >nul 2>&1
goto :eof
:: 递归搜索子文件夹,但不进入 target、.git、.idea
:search_subfolders
set "current_dir=%~1"
for %%d in (target .git .idea) do (
if exist "!current_dir!\%%d\" (
set "folder=!current_dir!\%%d"
call :process_folder
)
)
:: 继续递归子文件夹(但不进入 target、.git、.idea)
for /f "delims=" %%f in ('dir /b /ad /a-h "!current_dir!*" 2^>nul') do (
if exist "!current_dir!\%%f\" (
set "subfolder=%%f"
if /i not "!subfolder!"=="target" if /i not "!subfolder!"==".git" if /i not "!subfolder!"==".idea" (
call :search_subfolders "!current_dir!\%%f"
)
)
)
goto :eof
16万+

被折叠的 条评论
为什么被折叠?



