cd /D "%~dp0"

REM ============================================
REM Script: refreshMSGraphSubscriptions.bat
REM Last Changed: $Id$
REM Usage: Run from /CUST/XXXX/Exchange folder
REM ============================================

REM Set mstamp to today's date in yyyymm format
for /f "tokens=2,3,4 delims=- " %%a in ('echo %date%') do set "mstamp=%%c%%b"

REM Get customer code from folder path
for %%a in ("%~dp0..\.") do set "cust=%%~nxa"

REM Define temp log path
set "exchtemp=..\..\..\TEMP\%cust%\Exchange"

REM Create directory if it doesn't exist
if not exist "%exchtemp%" (
    mkdir "%exchtemp%"
)

REM Run the webhook refresh script and log output
cscript ..\..\..\UTILS\Exchange\refresh_webhooks.wsf >>"%exchtemp%\%~n0_%mstamp%.log" 2>>&1
