Link to home
Start Free TrialLog in
Avatar of epicazo
epicazoFlag for United States of America

asked on

Copy latest file that starts with "C36"

Need a script that would copy the latest (modified date) file that starts with “c36”

FILE:  C36*.TXT (if duplicate exists, then copy only the lates file)
SOURCE = \\d9d75pardb01\Paragon Upload Files\Remittances\  
TARGET = \\ela-ps1\medicare remits$\Mcare 835 ERAs\

The folder will ocasionally have more than one file with same date, but different times:

FILE NAME, CREATE DATE
C2500013352A, 06/23/2013@1601
C360005edc1D, 06/24/2013@1055
C25000urf1055, 06/24/2013@1055
C36000qwe255, 06/24/2013@1315  <<<  i want to be able to copy only this file >>>>

REM - SETTING VARIABLES
setlocal enabledelayedexpansion
set Source=\\d9d75pardb01\Paragon

REM - SEARCH FOR EXISTING FILES
for /f "tokens=1 delims=[]" %%a in ('type "%~f0" ^| find /n "[BACKUPDATA]"') do set DataStart=%%a
set /a TypeCount = 0

REM - COPY 
for /f "tokens=1* skip=%DataStart% delims= " %%a in ('type "%~f0"') do (
	set /a TypeCount += 1
	set SourceType[!TypeCount!]=%%a
	set Target[!TypeCount!]=%%b
)
for /l %%i in (1, 1, %TypeCount%) do (
	robocopy.exe "%Source%" "!Target[%%i]!" !SourceType[%%i]! /MIR /r:2 /w:1
)
goto :eof
[BACKUPDATA]
C36*.* \\ela-ps1\medicare remits$\Mcare 835 ERAs\

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of telczj9
telczj9

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LeeTutor
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
Avatar of epicazo

ASKER

sorry for the delay.  thank you so much