Solved

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

Posted on 2013-01-10
2
1,888 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
[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
2 Comments
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

617 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