Skip to content

Instantly share code, notes, and snippets.

@NobleUplift
Created September 5, 2015 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NobleUplift/ed4bd5fc994d1ca54b5a to your computer and use it in GitHub Desktop.
Save NobleUplift/ed4bd5fc994d1ca54b5a to your computer and use it in GitHub Desktop.
Symlinks every file in a hierarchy to one folder. Useful for Windows 7 Wallpapers.
@ECHO OFF
IF [%1]==[] (
ECHO Missing root source directory! Cannot continue.
EXIT /B
)
IF [%2]==[] (
ECHO Missing destination virtual directory! Cannot continue.
EXIT /B
)
IF NOT EXIST "%~f2\%~n1" (
MD "%~f2\%~n1"
ECHO Creating root destination directory.
)
IF NOT EXIST "%~f2\Blacklist" (
MD "%~f2\Blacklist"
ECHO Creating destination blacklist directory.
)
%~d1
CD %1
MKDIR "%WINDIR%\System32\test"
IF "%ERRORLEVEL%" == "0" (
RMDIR "%WINDIR%\System32\test"
MOVE "%~f2\Blacklist\%~n1 Blacklist.txt" "%~f2\Blacklist\%~n1 Blacklist.txt.bak"
ECHO. > "%~f2\Blacklist\%~n1 Blacklist.txt"
FOR /F "delims=|" %%F IN ('DIR /B .') DO (
IF EXIST %%~sF\NUL (
CD %%F
FOR /F "delims=|" %%I IN ('DIR /B .') DO (
IF NOT EXIST "%~f2\Blacklist\%%I" (
IF NOT EXIST "%~f2\%~n1\%%I" (
MKLINK "%~f2\%~n1\%%I" "%CD%\%%F\%%I"
ECHO Linked %CD%\%%F\%%I to %~f2\%~n1\%%I
) ELSE (
ECHO Link already exists: %~f2\%~n1\%%I
)
) ELSE (
ECHO %~f2\%~n1\%%I >> "%~f2\Blacklist\%~n1 Blacklist.txt"
ECHO Link blacklisted: %~f2\%~n1\%%I
)
)
CD ..
) ELSE (
MKLINK "%2\%~n1\%%F" "%CD%\%%F"
ECHO Linked %CD%\%%F to %2\%~n1\%%F
)
)
REM DIR /B "%~f2\%~n1 Blacklist" > "%~f2\Blacklist\%~n1 Blacklist.txt"
PAUSE
) ELSE (
echo Cannot run script, not an administrator.
PAUSE
)
%~d2
CD %2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment