Skip to content

Instantly share code, notes, and snippets.

@NobleUplift
Created September 17, 2016 20:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NobleUplift/e88db90b2ff621743f0a4c4ad8e3aa37 to your computer and use it in GitHub Desktop.
Save NobleUplift/e88db90b2ff621743f0a4c4ad8e3aa37 to your computer and use it in GitHub Desktop.
Syncs mirrored AppData directory on data drive D:\Users\%USERNAME%\AppData\Roaming with %APPDATA%
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
FOR %%T IN (D:\Users\%USERNAME%\AppData\Local D:\Users\%USERNAME%\AppData\Roaming D:\Users\%USERNAME%\AppData\Roaming\Microsoft\UProof) DO (
SET source=%%T
SET destination=!source:D:\=C:\!
FOR /F "delims=" %%F IN ('DIR /B "%%T"') DO (
IF EXIST !source!\%%F\NUL (
IF NOT EXIST "!destination!\%%F" (
MKLINK /J "!destination!\%%F" "!source!\%%F"
) ELSE (
FOR %%L IN ("!destination!\%%F") DO SET attribs=%%~aL
IF "!attribs:~8,1!" == "l" (
ECHO Folder !destination!\%%F is already linked to "!source!\%%F".
) ELSE (
ECHO Folder !destination!\%%F exists. Please resolve.
)
)
) ELSE (
IF NOT EXIST "!destination!\%%F" (
MKLINK "!destination!\%%F" "%%T\%%F"
) ELSE (
FOR %%L IN ("!destination!\%%F") DO SET attribs=%%~aL
IF "!attribs:~8,1!" == "l" (
ECHO File !destination!\%%F is already linked to "!source!\%%F".
) ELSE (
ECHO File !destination!\%%F exists. Please resolve.
)
)
)
)
)
ENDLOCAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment