I have a process at work where 'Workday' (an HR tool) drops off a set of files on a share. Then, my process picks them up and processes them.
However, the files they drop off have weird naming conventions, so I rename them to a format more easily digestible for my automation.
My script right now is, somewhat, but sometimes no matter what's in %%H, it gets over written with the last rename line:
Code: Select all
PUSHD "%HC_PROCPATH%"
SETLOCAL ENABLEDELAYEDEXPANSION
SET "A=0"
SET "NF1="
FOR %%H IN (
Zurich_Finance
Deerfield_-_Finance_CW_Headcount
Deerfield_-_Finance_Employee_Headcount_IA
Deerfield_-_Finance_Employee_Headcount ) DO (
IF EXIST %%H* (
ECHO Headcount File Detected ^: %%H*.%EXT% >>"%LOGFILE%"
ECHO %%H* | FINDSTR "CW">nul && REN "%%H*" "Contractors_%HC_STRING%_CW.%EXT%"
ECHO %%H* | FINDSTR "IA">nul && REN "%%H*" "Secondees_%HC_STRING%_IA.%EXT%"
ECHO %%H* | FINDSTR "Zurich">nul && REN "%%H*" "%HC_ZUR%.%EXT%"
REN "%%H*" "Employees_%HC_STRING%.%EXT%"
) ELSE (
SET /A A+=1
)
IF !A!==4 SET "NF1=T"& GOTO AbnormalExit
CLS
)
POPD
I'm using a wildcard because the strings dates and other characters on the end. Is there a better way to do this?
Thanks!