Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Copy latest file that starts with "C36"

Posted on 2013-06-24
4
Medium Priority
?
311 Views
Last Modified: 2013-07-18
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

0
Comment
Question by:epicazo
3 Comments
 
LVL 3

Accepted Solution

by:
telczj9 earned 2000 total points
ID: 39272415
the code below will copy newest file matching the C36*.TXT creteria:

@echo off
REM -- 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\


for /f "tokens=*" %%i in ('dir /od /b %SOURCE%\C36*.TXT') do (
 set freshesh_c36_file=%%i
) 

copy %SOURCE%\%freshesh_c36_file% %TARGET%

Open in new window

0
 
LVL 59

Expert Comment

by:LeeTutor
ID: 39336864
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 

Author Closing Comment

by:epicazo
ID: 39336865
sorry for the delay.  thank you so much
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question