@echo off
echo RebuildDailies - Copying 0MoveToCurrent.bat to all daily_* folders...
echo.

REM Check if source file exists
if not exist "A:\1 Amazon_Active_Projects\3 ProjectStructure\scripts_old\0MoveToCurrent.bat" (
    echo ERROR: Source file "A:\1 Amazon_Active_Projects\3 ProjectStructure\scripts_old\0MoveToCurrent.bat" not found!
    pause
    exit /b 1
)

REM Search for daily_* folders recursively
echo Searching for daily_* folders in all subfolders...
echo.

REM Show which folders will be updated
echo Found the following daily_* folders:
for /f "delims=" %%D in ('dir /s /b /ad "*daily_*" 2^>nul') do echo   - %%D

echo.
echo Copying 0MoveToCurrent.bat to each folder...
echo.

REM Copy the file to each daily_* folder found recursively
set /a count=0
for /f "delims=" %%D in ('dir /s /b /ad "*daily_*" 2^>nul') do (
    echo Copying to %%D...
    copy /Y "A:\1 Amazon_Active_Projects\3 ProjectStructure\scripts_old\0MoveToCurrent.bat" "%%D\" >nul
    if errorlevel 1 (
        echo   ERROR: Failed to copy to %%D
    ) else (
        echo   SUCCESS: Copied to %%D
        set /a count+=1
    )
)

echo.
echo Operation completed. Successfully copied to %count% folders.
pause 