Solved

Specify filename in Robocopy script

Posted on 2010-08-18
10
845 Views
Last Modified: 2012-05-10
Hi

I asked a question here about Robocopy on Windows 2003 server that Experts were really helpful on (thanks again!)

http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_26411867.html#a33467962

To summarise, here is the situation:

"I have a Windows 2003 server where I have an application that logs daily files. The folder is C:\Logs, and each day, a folder with the date is created and, within this, a log file with the date too.

For example:

C:\Logs\20100812\Log_20100812.txt

This process continues. So, after a week, I would have folders such as:

C:\Logs\20100813
C:\Logs\20100814
C:\Logs\20100815

etc, each with their own log file within.
"

I was planning on using this command to copy the previous day's log files;

robocopy \\server\c$\logs\\ \\server2\c$\copied\\  /maxage:2 /minage:1 /s

But, I notice that the app also creates some other files in each day's log folder that I don't need - all I need is the txt file starting with "log_<date>" - does anyone know how/if I can configure Robocopy to only copy over files that start with a certain name?
0
Comment
Question by:chuckp2010
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 5

Assisted Solution

by:belowzerotech
belowzerotech earned 166 total points
ID: 33468170
you can probably use an asterisk as a wildcard. for example, C:\logs\2010*
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 33468225
there are options for include and exclude certain files in robocopy.
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 33468264
for excluding

 
/XF file [file]      Excludes files with the specified names, paths, or wildcard characters.         
/XD dir [dir]      Excludes directories with the specified names, paths, or wildcard characters.       

0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 14

Expert Comment

by:athomsfere
ID: 33468308
If they are only .txt files for example, then add *.txt and it will only copy the .txt files, as well as search for all .txt files in the folder.
0
 

Author Comment

by:chuckp2010
ID: 33468345
Thanks guys - I saw the switches to exclude, but not to include?
0
 
LVL 63

Accepted Solution

by:
SysExpert earned 167 total points
ID: 33468418
No Include option- default is everything.

C:\logs\20*\*.txt  or C:\logs\20*\Log*.txt  may work

you need to test

0
 
LVL 11

Expert Comment

by:Ben Personick
ID: 33468761
Here you are. =)

Robocopy "\\Server\C$\Logs" "\\Server2\C$\Copied" *LOG_* /ZB /MINAGE:1 /MAXAGE:2 /S
0
 
LVL 11

Assisted Solution

by:Ben Personick
Ben Personick earned 167 total points
ID: 33468780
looks like you don;t even need *LOG_* since it always starts log, so I would change it to this:

Robocopy "\\Server\C$\Logs" "\\Server2\C$\Copied" LOG_* /ZB /MINAGE:1 /MAXAGE:2 /S



Robocopy "\\Server\C$\Logs" "\\Server2\C$\Copied" LOG_* /ZB /MINAGE:1 /MAXAGE:2 /S

Open in new window

0
 
LVL 16

Expert Comment

by:t0t0
ID: 33474081
robocopy \\server\c$\logs\\ \\server2\c$\copied\\ log_* /maxage:2 /minage:1 /s
0
 
LVL 16

Expert Comment

by:t0t0
ID: 33474087
wow! there were only THREE replies a mo ago. ah well, better late than never!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
network copying issue 4 65
PowerShell one liner to pull server names 3 59
how to use wail2ban ?? 13 119
Help with simple script. 8 35
Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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