Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
ashok1203
Creator II
Creator II

Required .bat file for copy latest file from one location to another location

Hi All,

Could you please provide me .bat file for copy the latest file from one location to another location.

Example: we have multiple files in the same folder like

1_201701.qvd

1_201702.qvd

2_201701.qvd

2_201702.qvd

Among the above qvd's i want to copy latest qvd i.e. starts with 2_201702.qvd.

Help me in this regard.

Regards,

Ashok

AAK
2 Replies
Not applicable

Hey,

Below will pick up newest file from C:/Source and copy it to C:/Destination.

::======= begin batch

@echo off & setlocal

for /r c:\Source %%a in (.) do (

call :xx "%%a"

)

goto :eof

:xx

for /f "tokens=*" %%b in ('dir /b /s /o-d /a-d %1') do (

echo copying %%~pnxb having date %%~tb

copy %%~pnxb c:\Destination

goto :eof

)

::====== end batch

BR,

Kuba

ashok1203
Creator II
Creator II
Author

Thanks Jakub.

AAK