213 shaares
1 résultat
taggé
batch
@ECHO off
SETLOCAL
:: script global variables
SET "CURRENT_LOCATION=%CD%"
SET "PATH_TO_FOLDER_TO_MOVE=%1"
SET "NAME_OF_FOLDER_TO_MOVE=%2"
SET "NEW_LOCATION_OF_FOLDER=%3"
ECHO ====================== SET INITIAL VARIABLES ======================
ECHO Param 1 : Path to current folder to move : %PATH_TO_FOLDER_TO_MOVE%
ECHO Param 2 : Name of the folder to move : %NAME_OF_FOLDER_TO_MOVE%
ECHO Param 3 : Path to new storage place : %NEW_LOCATION_OF_FOLDER%
ECHO Current location is %CURRENT_LOCATION%
ECHO.
ECHO ====================== START THE REPLACING WITH SYMLINK ======================
:: do something cool, then log it
CALL :replaceWithSymLink %PATH_TO_FOLDER_TO_MOVE% %NAME_OF_FOLDER_TO_MOVE% %NEW_LOCATION_OF_FOLDER%
ECHO.
ECHO ====================== END OF PROCESS ======================
ECHO Back to starting point !
CD %CURRENT_LOCATION%
EXIT 0
:: a function to move a folder to another place, and set a symbolic link instead
:: Param 1 : Path to current folder to move, end with /
:: Param 2 : Name of the folder to move
:: Param 3 : Path to new storage place, end with /
:replaceWithSymLink
ECHO.
CD %~1
ECHO CREATE DESTINATION FOLDER %~3%~2
mkdir %~3%~2
ECHO Move folder %~1%~2 to new destination %~3
ECHO "COPY %~1%~2 %~3%~2"
COPY %~1%~2 %~3%~2
ECHO "RMDIR /S /Q %~1%~2"
RMDIR /S /Q %~1%~2
ECHO Create symlink to TargetFile %~3%~2
ECHO mklink /D %~1%~2 %~3%~2
mklink /D %~1%~2 %~3%~2
EXIT /B 0
Pour l'appeler :
script.cmd "U:\workarea\" TESTENTRYPOINT "C:\TEST\"