bat文件内容
@echo off
setlocal enabledelayedexpansion
echo.
echo =================================
echo 运行提示:
echo 1、遍历删除指定目录下工程目录中的隐藏文件.git
echo 2、遍历推送工程目录到远程git仓库分支
echo =================================
echo.
rem echo 【当前目录:%~dp0】
echo.
echo.
:inputLoop
rem 提示用户输入路径或按回车键获取当前路径
set "directoryPath="
set /p "directoryPath=请输入目录路径 (按回车键获取当前路径): "
rem 如果用户未输入任何内容,则使用当前路径
if "!directoryPath!"=="" (
set "directoryPath=%cd%"
echo 【当前所在目录】!directoryPath!
)
rem 检查目录是否存在
if exist "!directoryPath!\" (
rem echo 【目录存在】%directoryPath%
echo.
) else (
echo 【目录不存在】%directoryPath%
echo 请重新输入有效的目录路径.
echo.
goto inputLoop
)
rem 列出目录A下的工程目录,并遍历它们
for /d %%i in ("%directoryPath%\*") do (
echo 【删除】【%%i】 目录中的隐藏文件 .git
rd /s /q "%%i\.git" 2>nul
echo 【推送】【 %%i】 目录到远程仓库的test分支
cd "%%i"
rem git push origin test
echo 【成功】【%%i】
cd ..
echo ------------------------------------
)
echo.
pause
endlocal