Solved How to copy folders using wildcards

dsikirica

New member
Local time
12:44 PM
Messages
8
i need to copy folders from one network drive to another drive each night. The structure of the folders are


10a
10b
10c
11a
11b
11c
12a
12b
12c

i only want to copy the folders starting with 12, there will be a random amount of folders created starting with 12 by the end of the year it could be up to 20 folders all starting with 12, i need to use a wildcard so i don't miss any of them. i would like to put the correct process in a batch file if possible but if not i can run each night manually

i can't seem to get this to work with copy , xcopy or robocopy

copy p:\client\12*. z:\clientbak\12*. /s this is an example of what i would like to do with whatever

copy program and with the correct syntax the above doesn't work with xcopy , copy or robocopy
 

My Computer My Computer

Computer Manufacturer/Model Number
custom build
OS
windows 7 ultimate 64 bit
CPU
i7
Motherboard
asus
Memory
12 gig
Graphics Card(s)
ati
Sound Card
n/a
Monitor(s) Displays
2 viewsonic
Hard Drives
sas
PSU
1000 watt
Case
cool master
Welcome Dsikirica to the windows 7 forum.
I suggest xcopy with the wildcard xcopy p:\client\12*.* z:\clientbak /s/i/m should copy the files you need
to the clientbak directory, creating the new directories if you wish.

Rich
 

My Computer My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Laptop Qosimo X870
OS
Windows 7 Pro x64 SP1
CPU
Intel Core I7
Motherboard
Toshiba Qosmio
Memory
16 Gigs
Graphics Card(s)
NVIDIA GeForce GTX 670M
Monitor(s) Displays
17.7" laptop
Screen Resolution
1600 x 900
Hard Drives
256 Gig SanDisk SSD for C
256 Gig Intel SSD for D
Internet Speed
50/25 FIOS
Antivirus
Vipre (all you can eat for 10 machines)
Browser
IE and FF
Other Info
I have dos 6.22, wfwg 3.11, win98, 2000 and xp VHD's available for testing. MS's Virtual PC works great.
thanks for replying: it said 0 files copied, it doesn't copy anything, i put a new file in one of the 12 folders to test it
 

My Computer My Computer

Computer Manufacturer/Model Number
custom build
OS
windows 7 ultimate 64 bit
CPU
i7
Motherboard
asus
Memory
12 gig
Graphics Card(s)
ati
Sound Card
n/a
Monitor(s) Displays
2 viewsonic
Hard Drives
sas
PSU
1000 watt
Case
cool master
Dsikirica, you are running the command prompt with administrators privs aren't you?

Rich
 

My Computer My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Laptop Qosimo X870
OS
Windows 7 Pro x64 SP1
CPU
Intel Core I7
Motherboard
Toshiba Qosmio
Memory
16 Gigs
Graphics Card(s)
NVIDIA GeForce GTX 670M
Monitor(s) Displays
17.7" laptop
Screen Resolution
1600 x 900
Hard Drives
256 Gig SanDisk SSD for C
256 Gig Intel SSD for D
Internet Speed
50/25 FIOS
Antivirus
Vipre (all you can eat for 10 machines)
Browser
IE and FF
Other Info
I have dos 6.22, wfwg 3.11, win98, 2000 and xp VHD's available for testing. MS's Virtual PC works great.
I know i had tried that, but it didn't seem to make a difference, so i tried it again making sure i was running it as administrator, it didn't work but it said invalid drive specification this time before 0 files copied

if i use dir instead of xcopy on the source it shows the folders just fine
if i use dir on the destination directory it shows that just fine also

not sure if that is a good test or not, but i didn't get an invalid drive specification
 

My Computer My Computer

Computer Manufacturer/Model Number
custom build
OS
windows 7 ultimate 64 bit
CPU
i7
Motherboard
asus
Memory
12 gig
Graphics Card(s)
ati
Sound Card
n/a
Monitor(s) Displays
2 viewsonic
Hard Drives
sas
PSU
1000 watt
Case
cool master
Dsikirica, copy and paste your exact batch command into a message, an invalid drive specification error might be because of misformed batch command.

Rich
 

My Computer My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Laptop Qosimo X870
OS
Windows 7 Pro x64 SP1
CPU
Intel Core I7
Motherboard
Toshiba Qosmio
Memory
16 Gigs
Graphics Card(s)
NVIDIA GeForce GTX 670M
Monitor(s) Displays
17.7" laptop
Screen Resolution
1600 x 900
Hard Drives
256 Gig SanDisk SSD for C
256 Gig Intel SSD for D
Internet Speed
50/25 FIOS
Antivirus
Vipre (all you can eat for 10 machines)
Browser
IE and FF
Other Info
I have dos 6.22, wfwg 3.11, win98, 2000 and xp VHD's available for testing. MS's Virtual PC works great.
xcopy p:\client\12*.* z:\clientbak\ /s /i /m
 

My Computer My Computer

Computer Manufacturer/Model Number
custom build
OS
windows 7 ultimate 64 bit
CPU
i7
Motherboard
asus
Memory
12 gig
Graphics Card(s)
ati
Sound Card
n/a
Monitor(s) Displays
2 viewsonic
Hard Drives
sas
PSU
1000 watt
Case
cool master
It might be because you are using a mapped drive. I would suggest trying on your c: drive to make sure the syntax works ok. copy from one location on C to another location on C, then try from P: to C: and then C: to Z:

You might see where the issue is occuring.
 

My Computer My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
ASUS G60-RBBX05
OS
Win7 Home Premium 64x
CPU
Intel Core 2 Duo P7450 / 2.13 GHz (2.29 with Extreme Turbo)
Memory
4 GB PC-6400 Hyundai (2X2) at 800Mhz
Graphics Card(s)
NVIDIA GeForce GTX 260M 1GB DDR3 VRAM
Monitor(s) Displays
16" LED Backlit
Screen Resolution
1366 x 768 on laptop 1600x1050 max res on 22" external mon
Hard Drives
OCZ Agility 3 60GB SSD / 320 GB - Serial ATA-150 - 7200 rpm
PSU
6-cell Lithium ion { lasts 1.5 hours }
Case
ASUS G60 Laptop
Keyboard
Chicklet type back-lit (white light) keyboard
Mouse
Logitech G9 Laser Mouse 3200dpi and 1000 reports per minute
Internet Speed
Comcast 8.60mb/s up - 3.11mb/s down
Antivirus
MSE
Browser
Firefox
Other Info
General mid-budget gaming Comp. Low batterylife - High FrameRates - currently overheating problems :(

2nd Rig: Case: Rosewill BLACKHAWK Gaming ATX Mid Tower Computer Case

Mobo: GIGABYTE GA-990FXA-UD3
CPU: AMD FX-6200 Zambezi 3.8GHz (4.1GHz Turbo)
Heatsink: COOLER MASTER V8 CPU Cooler
RAM: Patriot Viper 3 8GB (2 x 4GB) 240-Pin DDR3 SDRAM 1866 (PC3 15000)
GPU: SAPPHIRE Radeon HD 6850 1GB 2
this is so frustrating, thanks for your help so far i really appreciate it

i copied the whole structure down to my c drive and tried to xcopy it to another local drvie G:

0 files copied

dir works with both ends of the xcopy command

maybe it's a windows 7 problem, i will try on an xp machine and let you know how that works, not sure that matters but worth a try
 

My Computer My Computer

Computer Manufacturer/Model Number
custom build
OS
windows 7 ultimate 64 bit
CPU
i7
Motherboard
asus
Memory
12 gig
Graphics Card(s)
ati
Sound Card
n/a
Monitor(s) Displays
2 viewsonic
Hard Drives
sas
PSU
1000 watt
Case
cool master
xcopy p:\client\12*.* z:\clientbak\ /e /i /m
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 8
that was close it copied the directory structure but it didn't copy any of the files inside the folders
 

My Computer My Computer

Computer Manufacturer/Model Number
custom build
OS
windows 7 ultimate 64 bit
CPU
i7
Motherboard
asus
Memory
12 gig
Graphics Card(s)
ati
Sound Card
n/a
Monitor(s) Displays
2 viewsonic
Hard Drives
sas
PSU
1000 watt
Case
cool master
dsikirica try

xcopy p:\client\12*.* z:\clientbak\ /e /i /s

The /m works only once until you reset the archive bit. Happens all the time when it fails the first
time. The archive bit gets set and the /m tells it that it already has been archived.

Rich
 

My Computer My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Laptop Qosimo X870
OS
Windows 7 Pro x64 SP1
CPU
Intel Core I7
Motherboard
Toshiba Qosmio
Memory
16 Gigs
Graphics Card(s)
NVIDIA GeForce GTX 670M
Monitor(s) Displays
17.7" laptop
Screen Resolution
1600 x 900
Hard Drives
256 Gig SanDisk SSD for C
256 Gig Intel SSD for D
Internet Speed
50/25 FIOS
Antivirus
Vipre (all you can eat for 10 machines)
Browser
IE and FF
Other Info
I have dos 6.22, wfwg 3.11, win98, 2000 and xp VHD's available for testing. MS's Virtual PC works great.
it copied all of the folders in the whole client directory, not just the ones that start with 12, it only copied 2 files under those folders, and they weren't the files in the 12*.* folders., is there anything you can think of that i need to do on my end different these are mapped drives and if it matters the folders are on two different servers, clients is on server x and clientbak is on server y
 

My Computer My Computer

Computer Manufacturer/Model Number
custom build
OS
windows 7 ultimate 64 bit
CPU
i7
Motherboard
asus
Memory
12 gig
Graphics Card(s)
ati
Sound Card
n/a
Monitor(s) Displays
2 viewsonic
Hard Drives
sas
PSU
1000 watt
Case
cool master
This is the closest I could get, try this in a batch file:

for /d %%a in (\client\12*) do xcopy "%%a" "z:\clientbak\%%a" /E /I

Use %a instead of %%a to run it from the command line.

This copies only the 12 folders & files BUT it copies them to clientbak\client. I wasn't able to get around that.
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Home Built desktop, Dell G15 5511 Gaming laptop,MS Surface Pro 7 tablet
OS
W10 Pro desktop, W11 laptop, W11 Pro tablet (all 64-bit)
CPU
3.7Ghz 8700K i7, i7-11800H, i7-1065G7
Motherboard
ASUS TUF Z370-Pro Gaming in desktop
Memory
16G desktop, 16G laptop, 4G tablet
Graphics Card(s)
AMD Radeon RX580, RTX 3060, Intel Iris Plus
Sound Card
High Definition Audio (Built-in to mobo)
Monitor(s) Displays
Samsung U32J59 32" (2x), 15.6", 12"
Screen Resolution
3840x2160, 3840x2160, 1920x1080, 2160x1440
Hard Drives
500G SSD for OS; 2T, 10T & 15T HDDs for Data on Desktop, 1TB SSD laptop, 128G SSD tablet.
PSU
Corsair CX 750M
Case
Antec 100
Cooling
CM 212+
Keyboard
IBM Model M - used continuously since 1986
Mouse
Microsoft Pro IntelliMouse
Internet Speed
400M down 8M up
Antivirus
Windows Defender
Browser
FireFox
Other Info
Built my first computer (8Mhz 8088cpu, 640K RAM, 20MB HDD, 2 360K floppy drives) in 1985 and have been building them for myself, relatives and friends ever since.
thanks so much, this works perfectly
 

My Computer My Computer

Computer Manufacturer/Model Number
custom build
OS
windows 7 ultimate 64 bit
CPU
i7
Motherboard
asus
Memory
12 gig
Graphics Card(s)
ati
Sound Card
n/a
Monitor(s) Displays
2 viewsonic
Hard Drives
sas
PSU
1000 watt
Case
cool master
Back
Top