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

x
?
Solved

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

Posted on 2013-01-10
2
Medium Priority
?
2,290 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:Clinton Smith
2 Comments
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 38765251
@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:Clinton Smith
ID: 38765278
That worked perfectly!! Thank you so much!!
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

916 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