Solved

I need a cmd- or bat-script that copies files based on a timeslot.

Posted on 2008-10-05
4
286 Views
Last Modified: 2010-04-21
Hello, I need a cmd or bat script (Windows XP/NT) that copies files based on a timeslot. The audiologging of my radiostation writes files in a directory. The files have a unique name (date and time, example: BNR_20081003_10h00).) Every half our a new file will be written, which is ready after a half hour. When the file is ready (a new file is already busy writing), I want ONLY the latest ready file to be copied to another (network)directory. In other words: the copy of the latest finished file may take place as soon as the file is ready an a new file is being writed. Who can help me with a simple cmd / bat script?
0
Comment
Question by:PatrickBNR
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 21

Expert Comment

by:AmazingTech
ID: 22653104
How were you going to have the script run? Does this folder only has these files? So 1 writing and the  others are old logs nothing else? And you want to copy not move these files?
0
 
LVL 21

Accepted Solution

by:
AmazingTech earned 50 total points
ID: 22653169
Here's a simple batch file that will skip the 1st newest file in the folder and copy only files that does not already exist in the destination.
Set AudioLogs=C:\AudioLogs
Set NetworkFolder=\\Server\Share
 
FOR /f "skip=1 tokens=*" %%a in ('dir /a-d /o-d /b "%AudioLogs%"') do (
    ECHO XCOPY /d "%AudioLogs%\%%a" "%NetworkFolder%\*.*"
)

Open in new window

0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 22653177
Of course you can use a UNC path for the AudioLogs as well.

Set AudioLogs=\\Server\AudioLogs

Remove the ECHO in front of XCOPY for it to copy.
0
 

Author Closing Comment

by:PatrickBNR
ID: 31503185
Thank you very much! I'm going to try and thinks it's going to work.
Many thanks from Patrick from Holland.
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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