I'm running xcopy within a Jenkins build.
I have the following directory structure:
Ensure\
a
Web_ERP
b
c
Web_ERP
Web_ERP
Web_ERP_Claims
Web_ERP_Finance
I'm trying to copy all folders which start with "Web_ER*" under Ensure (depth=1) to my current workspace.
node () {
stage ('Setup') {
deleteDir()
bat '''
IF NOT EXIST c:\\deploy mkdir c:\\deploy
cd ..\\Ensure
xcopy Web_ER* "%WORKSPACE%" /e
'''
}
}
In reality, all the folders which start with Web_ER* are being copied along with Web_ER* folders which reside under folders a and c.
I want only Web_ER* folders which reside under Ensure to be copied along with their content.
I've tried the following switches with xcopy: /i /e /s /m but I get the same result every time.
Edit #1:
@magoo when I run the command you gave it copies all the files which are under each one of the Web_ER* folders without the folders themselves, I want to copy all the folders strating with "Web_ER*" with all their subdirectories to my destination folder. Following your example I've also tried:
for /f "delims=" %%a in ('dir /b /ad web_er*') do xcopy ".\\%%a" "%WORKSPACE%" /e /y
But to no avail.
In linux for example it's as easy as:
cp -R folder/pattern* destination/dir
I'm looking for the equivalent command in windows.
What am I doing wrong?
for /f "delims=" %%a in ('dir /b /ad web_er*') do xcopy ".\%%a\*" "%WORKSPACE%" /e
should accomplish this. Process a directory list in /b
basic (name-only) form /ad
of directorynames matching web_er*
in the current directory, and apply each name found in turn to %%a
; then xcopy
all of the files.