charmedimsure
asked on
Copy a file to a folder using wildcards at MS-DOS Prompt
I have a Word doc named z123.doc I need to copy it to a several similar folder paths
The similar folder paths are G:\Specialty Services(\in here is there userid i.e. jdoe this part changes)\Word
I tried copy C:\z123.doc G:\Specialty Services\*\Word\ in MS Dos but it did not work
What syntax do I need to use to get this to work?
Thanks
The similar folder paths are G:\Specialty Services(\in here is there userid i.e. jdoe this part changes)\Word
I tried copy C:\z123.doc G:\Specialty Services\*\Word\ in MS Dos but it did not work
What syntax do I need to use to get this to work?
Thanks
The first section of the copy is the to location, the second part is the from location.
ASKER
So what should the syntax be then?
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
you can try this:
@echo off
for /F %%a in ('dir /b /ad c:\temp') do copy C:\z123.doc G:\SpecialtyServices\%%a\W ord
or vbscript:
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
srcDir = "G:\SpecialtyServices"
srcFile = "C:\z123.doc"
Set objFolder = objFSO.GetFolder(srcDir)
For Each folder In objFolder.SubFolders
objFSO.CopyFile srcFile , folder.Path&"\"&"z123.doc"
Next
Set objFolder=Nothing
Set objFSO=Nothing
save as myscript.vbs and on command prompt, type: cscript /nologo myscript.vbs
@echo off
for /F %%a in ('dir /b /ad c:\temp') do copy C:\z123.doc G:\SpecialtyServices\%%a\W
or vbscript:
Set objFSO = CreateObject("Scripting.Fi
srcDir = "G:\SpecialtyServices"
srcFile = "C:\z123.doc"
Set objFolder = objFSO.GetFolder(srcDir)
For Each folder In objFolder.SubFolders
objFSO.CopyFile srcFile , folder.Path&"\"&"z123.doc"
Next
Set objFolder=Nothing
Set objFSO=Nothing
save as myscript.vbs and on command prompt, type: cscript /nologo myscript.vbs
*Hi Fives* @ SteveGTR... You hit it right on the nail. Thanks!