|
| 1 | +@echo off |
| 2 | +setlocal enabledelayedexpansion |
| 3 | + |
| 4 | +:: Base paths for symbolic links based on folder names |
| 5 | +set hdrp_target=..\..\..\com.unity.toonshader\Samples~\HDRP |
| 6 | +set urp_target=..\..\..\com.unity.toonshader\Samples~\URP |
| 7 | +set builtin_target=..\..\..\com.unity.toonshader\Samples~\Legacy |
| 8 | + |
| 9 | +set hdrp_sample_symlink_name=SamplesHDRP |
| 10 | +set urp_sample_symlink_name=SamplesURP |
| 11 | +set builtin_sample_symlink_name=SamplesBuiltIn |
| 12 | + |
| 13 | +:: Directory to operate on |
| 14 | +set test_projects_dir=TestProjects |
| 15 | + |
| 16 | +:: Loop through all folders in the TestProjects directory |
| 17 | +for /d %%F in ("%test_projects_dir%\*") do ( |
| 18 | + :: Extract only the folder name (without the path) |
| 19 | + set folder_name=%%~nF |
| 20 | + |
| 21 | + :: Check if the folder name contains "HDRP", "Universal", or "Legacy" |
| 22 | + set target_path= |
| 23 | + set symlink_name= |
| 24 | + echo !folder_name! | findstr /i "HDRP" >nul |
| 25 | + if !errorlevel! equ 0 ( |
| 26 | + set target_path=%hdrp_target% |
| 27 | + set symlink_name=%hdrp_sample_symlink_name% |
| 28 | + ) else ( |
| 29 | + echo !folder_name! | findstr /i "Universal" >nul |
| 30 | + if !errorlevel! equ 0 ( |
| 31 | + set target_path=%urp_target% |
| 32 | + set symlink_name=%urp_sample_symlink_name% |
| 33 | + ) else ( |
| 34 | + echo !folder_name! | findstr /i "Legacy" >nul |
| 35 | + if !errorlevel! equ 0 ( |
| 36 | + set target_path=%builtin_target% |
| 37 | + set symlink_name=%builtin_sample_symlink_name% |
| 38 | + ) |
| 39 | + ) |
| 40 | + ) |
| 41 | + |
| 42 | + |
| 43 | + :: Create the symbolic link if a target path is defined |
| 44 | + if defined target_path ( |
| 45 | + |
| 46 | + :: Store the full path to the symbolic link in a variable |
| 47 | + set symlink_full_path=%%F\Assets\!symlink_name! |
| 48 | + |
| 49 | + if exist "!symlink_full_path!" ( |
| 50 | + rem echo Deleting existing link or folder: "!symlink_full_path!" |
| 51 | + rmdir "!symlink_full_path!" |
| 52 | + ) |
| 53 | + rem echo Creating symbolic link "!symlink_full_path!" targeting "!target_path!" |
| 54 | + mklink /d "!symlink_full_path!" "!target_path!" |
| 55 | + |
| 56 | + ) |
| 57 | +) |
| 58 | + |
| 59 | +echo All done! |
0 commit comments