Solved

Using a batch file to copy files with a wildcard in the directory path

Posted on 2013-01-10
2
1,535 Views
Last Modified: 2013-01-10
I am writing a batch file to copy all files ending in .log to another directory.
The issue is that in the middle of the path, the folder name can be different.
Example:
xcopy "C:\Jobs\P0026\VB\Logs" "\\networkpath"

or on another machine it could be:

xcopy "C:\Jobs\P0075\VB\Logs" "\\networkpath"

depending on which program is running.

I basically need to declare a wildcard or variable for the P00* folder.
0
Comment
Question by:TS Tech USA
2 Comments
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
Comment Utility
@echo off
for /D %%D in (C:\Jobs\P00*) do xcopy "%%~D\VB\Logs" "\\network\path"

Open in new window

should be the fastest method to do that.
0
 

Author Closing Comment

by:TS Tech USA
Comment Utility
That worked perfectly!! Thank you so much!!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now