• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

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

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
PatrickBNR
Asked:
PatrickBNR
  • 3
1 Solution
 
AmazingTechCommented:
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
 
AmazingTechCommented:
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
 
AmazingTechCommented:
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
 
PatrickBNRAuthor Commented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now