::参考内存盘软件https://download.csdn.net/download/zly6tz/9717137
cls
@echo off
::内存虚拟盘符-内存盘大小自己查看源目录大小
::下面是设置vs2008,vs插件VisualAssist,chrome,我设置的是8G,目前使用了2.3g
::此内存盘需要设置对应文件-开机时加载,关机保存即可
@SET VDisk=S:
echo 正在努力工作...
::下面的项 自己按需修改
call :SRCopyMKLink "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7" "%VDisk%\vs.Common7"
call :SRCopyMKLink "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC" "%VDisk%\vs.VC"
call :SRCopyMKLink "C:\Users\Administrator\AppData\Roaming\Microsoft\VisualStudio\9.0" "%VDisk%\vs.Roaming"
call :SRCopyMKLink "C:\Users\Administrator\AppData\Local\VisualAssist" "%VDisk%\VisualAssist"
call :SRCopyMKLink "C:\Users\Administrator\AppData\Local\Google\Chrome" "%VDisk%\Chrome"
@goto end
::自动备份目录 并联接
:SRCopyMKLink
@set srcDir=%~1
@set toDir=%~2
@SET srcName=%~nx1
@SET toName=%~nx2
::变态的bat,函数中的if exist路径包含括号时出鬼,只能用cd来处理
cd /d "%~dp1"
if not exist %srcName%_SRBAK (
::判断源路径是否存在
if not exist "%srcName%" (
echo 源目录不存在:%srcName%
goto toerror
)
rename "%srcName%" "%srcName%_SRBAK"
if not exist "%srcName%_SRBAK" (
echo 修改源目录名失败:%srcName%
goto toerror
)
)
::处理目标路径
if not exist "%toDir%" (
::创建一个临时目录
md "%toDir%_tmp"
xcopy "%srcName%_SRBAK\*.*" "%toDir%_tmp\" /s /e /y /h /r /Q
if not %errorlevel%==0 (
echo 复制文件失败:源:%srcName%
goto toerror
)
::将临时目录名修改回来
ren "%toDir%_tmp" "%toName%"
if not exist "%toDir%" (
echo 修改目标路径失败:%srcName%
goto toerror
)
)
if exist "%srcName%_SRBAK" (
if exist "%srcName%" (
::删除源目录名
rd /s /q %srcName%
if exist "%srcName%" (
echo 删除源链接失败:%srcName%
goto toerror
)
)
mklink /j "%srcName%" "%toDir%"
if not %errorlevel%==0 (
echo 链接失败:%srcName%
goto toerror
)
)
:tosuccess
@exit /B 0
:toerror
echo 发生了错误
@exit /B 1
:end
pause