Files
ProjectStructure/NewProject.bat

95 lines
4.2 KiB
Batchfile
Raw Permalink Normal View History

2025-08-08 13:33:08 -06:00
@echo off
2025-11-08 02:36:20 -07:00
setlocal EnableExtensions
2026-01-02 16:37:53 -07:00
:: Search for .config directory in current working directory (including subdirectories) to find ProjectStructure location
set "STRUCT_DIR="
for /f "usebackq delims=" %%I in (`powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"$ErrorActionPreference = 'Continue'; $searchDir = '%CD%'; try { $subDirs = Get-ChildItem -LiteralPath $searchDir -Directory -Force -ErrorAction Stop; $configDirs = @(); foreach ($subDir in $subDirs) { $configPath = Join-Path $subDir.FullName '.config\config.json'; if (Test-Path -LiteralPath $configPath -PathType Leaf) { $configDirs += $configPath } }; if ($configDirs.Count -gt 0) { $configPath = $configDirs[0]; $config = Get-Content -LiteralPath $configPath -Raw | ConvertFrom-Json; if ($config.structDir) { $structDir = $config.structDir.ToString().Trim(); if ([System.IO.Path]::IsPathRooted($structDir)) { try { $resolved = Resolve-Path -LiteralPath $structDir -ErrorAction Stop; Write-Output $resolved.Path } catch { Write-Output $structDir } } else { $candidate = Join-Path (Split-Path -Parent $configPath) $structDir; try { $resolvedCandidate = Resolve-Path -LiteralPath $candidate -ErrorAction Stop; Write-Output $resolvedCandidate.Path } catch { Write-Output $candidate } } } } } catch { }"`) do set "STRUCT_DIR=%%I"
2025-11-08 02:36:20 -07:00
2026-01-02 16:37:53 -07:00
if not defined STRUCT_DIR (
echo [ERROR] Unable to find .config directory or resolve ProjectStructure directory.
echo Please ensure you are running NewProject.bat from a directory containing projects with .config folders.
2025-11-08 02:36:20 -07:00
exit /b 1
)
2026-01-02 16:37:53 -07:00
:: Debug: Show discovered structDir
echo Found ProjectStructure directory: %STRUCT_DIR%
2025-11-08 02:36:20 -07:00
2026-01-02 16:37:53 -07:00
:: Locate ConfigLoader.ps1 in the ProjectStructure directory
set "CONFIG_LOADER=%STRUCT_DIR%\ConfigLoader.ps1"
2025-11-08 02:36:20 -07:00
2026-01-02 16:37:53 -07:00
if not exist "%CONFIG_LOADER%" (
echo [ERROR] ConfigLoader.ps1 not found at: %CONFIG_LOADER%
2025-11-08 02:36:20 -07:00
exit /b 1
)
2025-08-08 13:33:08 -06:00
2025-08-17 14:22:09 -06:00
:: Get current date in YYYY-MM-DD format
2025-08-08 13:33:08 -06:00
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (
set mm=%%a
set dd=%%b
set yy=%%c
)
2025-08-17 14:22:09 -06:00
set yyyy=20%yy:~-2%
set yymmdd=%yy:~-2%%mm%%dd%
2025-08-08 13:33:08 -06:00
:: Ask for project name
set /p projectName="Enter project name (press Enter for default 'NewProject'): "
if "%projectName%"=="" set projectName=NewProject
set projectRoot=%yymmdd%_%projectName%
2025-08-08 13:33:08 -06:00
:: Create main project directory
mkdir "%projectRoot%"
:: Create Assets structure
mkdir "%projectRoot%\Assets\ElevenLabs"
2025-11-08 02:36:20 -07:00
if exist "%STRUCT_DIR%\NewDaily.bat" copy /Y "%STRUCT_DIR%\NewDaily.bat" "%projectRoot%\Assets\ElevenLabs\NewDaily.bat" >nul
2025-08-08 13:33:08 -06:00
mkdir "%projectRoot%\Assets\Blends"
2025-09-17 09:42:32 -06:00
mkdir "%projectRoot%\Assets\Mocap"
2025-08-08 13:33:08 -06:00
mkdir "%projectRoot%\Assets\VO"
2025-09-16 22:11:55 -06:00
if exist "%~dp0NewDaily.bat" copy /Y "%~dp0NewDaily.bat" "%projectRoot%\Assets\VO\NewDaily.bat" >nul
2025-08-08 13:33:08 -06:00
:: Create Blends structure
mkdir "%projectRoot%\Blends\animations\"
2025-08-08 13:33:08 -06:00
mkdir "%projectRoot%\Blends\stills\img-BG"
:: Create Deliverable structure
mkdir "%projectRoot%\Deliverable\"
:: Create Pr structure
mkdir "%projectRoot%\Pr\RnR\RIFE"
2025-08-08 16:48:08 -06:00
:: Add project root additions
if not exist "%projectRoot%\Renders" mkdir "%projectRoot%\Renders"
2026-02-02 16:40:18 -07:00
:: Place helper scripts into Renders (config lives in .config\, deployed by ConfigLoader below)
2025-11-08 02:36:20 -07:00
set "templateRoot=%STRUCT_DIR%"
2026-02-02 17:19:54 -07:00
for %%F in (UpdateSequences.bat ZipSeqArchv.bat UnzipSeqArchv.bat CompressPNGs.bat) do (
2025-11-08 02:36:20 -07:00
if exist "%templateRoot%\%%F" copy /Y "%templateRoot%\%%F" "%projectRoot%\Renders\%%F" >nul
)
2025-08-08 16:48:08 -06:00
:: Use repo-provided templates for git config files
2025-08-17 14:27:16 -06:00
if exist "%~dp0components\gitignore" copy /Y "%~dp0components\gitignore" "%projectRoot%\.gitignore" >nul
if exist "%~dp0components\gitattributes" copy /Y "%~dp0components\gitattributes" "%projectRoot%\.gitattributes" >nul
2025-08-08 16:48:08 -06:00
:: Initialize git and install Git LFS
pushd "%projectRoot%" >nul
git init
git lfs install
2025-08-20 14:40:49 -06:00
git add . -v
git commit -m "init"
2025-08-08 16:48:08 -06:00
popd >nul
2025-08-08 13:33:08 -06:00
2026-01-02 16:37:53 -07:00
:: Deploy config workflow using ConfigLoader.ps1
echo.
echo Deploying config workflow...
for %%P in ("%projectRoot%") do set "PROJECT_ROOT_ABS=%%~fP"
powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%CONFIG_LOADER%' -ProjectPath '%PROJECT_ROOT_ABS%'"
if errorlevel 1 (
echo [WARNING] Config workflow deployment failed. You may need to run ConfigLoader.ps1 manually.
) else (
echo Config workflow deployed successfully.
)
2025-08-08 13:33:08 -06:00
echo Project structure created successfully in folder: %projectRoot%
pause