Solved

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

Posted on 2013-01-10
2
1,604 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 69

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

805 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