Question

I'm trying to take the newest file from a directory that begins with LEEXTR_DC30 and copy it to another directory. The source file is dated. I would also like to get rid of the date and just save it to the new directory as LEEXTR_DC30.txt. I then want to delete the copied file at a specific time.... Any help would be greatly appreciated!! I have a start below... The original file is named something like this (depending on day it's created) LEEXTR_DC30_201404180915a_1.txt

copy "\\taaproc0200a\D$\hbc\data\dc\backup\LEEXTR_DC30*.txt" "D:\Kronos\InterfaceDesigner\DA DC Interface\Associate\DCXX Associate Files"
exit /b 0
Was it helpful?

Solution

rem get latest file:
for /f "tokens=*" %%i in ('dir "\\taaproc0200a\D$\hbc\data\dc\backup\LEEXTR_DC30*.txt" /s /od /b') do set a=%%i
rem copy it:
copy "%a% "D:\Kronos\InterfaceDesigner\DA DC Interface\Associate\DCXX Associate Files\LEEXTR_DC30.txt"

As for "delete the copied file at a specific time" - can you specify this? After x days? On next Monday? If there is a new version?

Last one would be easy: no need to delete, just overwrite it. (copy-parameter /y)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top