I'm having a little trouble and hope someone here can help me out.
The code below copies the latest version of a file to my target directory. I'm wanting to also open the latest file that was copied into my target directory. The filename isnt constant, so it needs to be able to find the most recent file to open.
@echo off
set source="N:\Project\c1662\shareddata\3d-Model-Index"
set target="C:\NWD"
ECHO Copying files..........please weait
FOR /F "delims=" %%I IN ('DIR %source%\*.nwd /A:-D /O:-D /B') DO COPY
%source%\"%%I" %target% & echo %%I & GOTO :END
:END
start "" "C:\Users\nortonjl\Desktop\Navisworks Simulate 2015.lnk"
???
:End
You want to open the latest file found from the for
loop. Here is a way you can do this:
@echo off
set "source=N:\Project\c1662\shareddata\3d-Model-Index"
set "target=C:\NWD"
echo Copying files..........please weait
for /f "delims=" %%I IN ('dir %source%\*.nwd /A:-D /O:-D /B') do (
copy "%%~fI" %target%
set "latest_file=%%~nxI"
echo %%I
)
goto END
:END
start "" "C:\Users\nortonjl\Desktop\Navisworks Simulate 2015.lnk"
start "" "%target%\%latest_file%"