:: Q:\Test18\SU1313056.cmd
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
:: Get date in a locale/user-settings independent format
for /f "tokens=1-3 delims=.+-" %%A in (
'wmic os get LocalDateTime^|findstr ^^[0-9]'
) do Set _DT=%%A
Set "yy=%_DT:~0,4%"&Set "MM=%_DT:~4,2%"&Set "dd=%_DT:~6,2%"
:: Build MonthName[01..12] array
Set i=100&Set "MonthName= January February March April May June July August September October November December"
Set "MonthName=%MonthName: ="&Set /a i+=1&Set "MonthName[!i:~-2!]=%"
:: Set MonthName
Set "Excel=C:\Program Files (x86)\Microsoft Office\Office14\excelcnv.exe"
Set "Src=H:\File Path\%yy%\Support\%MM% !MonthName[%MM%]!\Other\%MM% Export.xls"
Set "Dst=%Src%x"
:: Show command
Echo "%Excel%" -oice^^
Echo "%Src%" ^^
Echo "%Dst%"
If Not exist "%Excel%" (Echo Can't find "%Excel%" & Pause & Exit /B 1)
If Not exist "%Src%" (Echo Can't find "%Src%" & Pause & Exit /B 1)
::DoIt
"%Excel%" -oice "%Src%" "%Dst%"
Exemplo de saída:
"C:\Program Files (x86)\Microsoft Office\Office14\excelcnv.exe" -oice^
"H:\File Path18\Support April\Other Export.xls" ^
"H:\File Path18\Support April\Other Export.xlsx"
Can't find "C:\Program Files (x86)\Microsoft Office\Office14\excelcnv.exe"
Can't find "H:\File Path18\Support April\Other Export.xls"