Created
September 26, 2025 04:16
-
-
Save nine1one/015559b1dbbc7d8eb29aa10b292238dd to your computer and use it in GitHub Desktop.
A Windows batch script that will crawl through each subdirectory in the current directory, check if it contains a .git folder, and then move the entire repository to %userprofile%\.github. It will create %userprofile%\.github if it doesn’t exist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| setlocal enabledelayedexpansion | |
| rem Set the source directory to %userprofile% | |
| set "SOURCE=%userprofile%" | |
| rem Set the target directory to %userprofile%\.github | |
| set "TARGET=%userprofile%\.github" | |
| rem Create the .github directory if it doesn't exist | |
| if not exist "%TARGET%" mkdir "%TARGET%" | |
| rem Change to the source directory | |
| cd /d "%SOURCE%" | |
| rem Loop through all subdirectories | |
| for /d %%D in (*) do ( | |
| rem Skip the .github directory itself | |
| if /i not "%%D"==".github" ( | |
| rem Check if the subdirectory contains a .git folder | |
| if exist "%%D\.git" ( | |
| echo Moving repository %%D to .github... | |
| move "%%D" "%TARGET%" | |
| ) | |
| ) | |
| ) | |
| echo Done! | |
| pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment