12345678910111213141516171819202122232425262728293031323334 |
- @echo off
- setlocal enabledelayedexpansion
-
- :: 获取当前目录的完整路径
- set "current_dir=%CD%"
-
- :: 提取当前目录的最后一个文件夹名称(不包括路径)
- for %%i in ("%current_dir%") do set "folder_name=%%~nxi"
-
- :: 去除路径中的最后一个反斜杠和文件名后的点(如果有的话,比如C:\folder.)
- :strip_trailing_slash_and_dot
- if "!folder_name:~-1!"=="\" (
- set "folder_name=!folder_name:~0,-1!"
- goto :strip_trailing_slash_and_dot
- )
- if "!folder_name:~-1!"=="." (
- set "folder_name=!folder_name:~0,-1!"
- goto :strip_trailing_slash_and_dot
- )
-
- :: 构建你的git命令
- set "git_command=git remote add origin http://git.cloudpeaks.cn/droplin/%folder_name%.git"
-
- :: 输出或执行你的git命令
- echo !git_command!
- :: 如果你要实际执行这个命令,取消下面的rem注释
- :: !git_command!
-
- git init
- !git_command!
- endlocal
- pause
|