Guest JohnB Posted June 30, 2008 Posted June 30, 2008 How would I do this: I have a server with a drive letter mapped to F: I need to copy some of the folders from F: to an existing folder on drive T:, which is on another server. Say the folder names on F: are Folder1 and Folder2. (there's actually about 10 folders) I want to copy Folder1 and Folder2 to drive T: How can I copy Folder1 and all it's sub-contents to T: without first creating a folder in the existing folder on T: I want to avoid, if possible, doing a: MD t:\Folder1 and copying the contents of F:\Folder1 In other words, I want the copy, or in this case, xcopy, command to create the folder name for me. Is there a way to do that? TIA
Guest Pegasus \(MVP\) Posted June 30, 2008 Posted June 30, 2008 Re: Another batch file question "JohnB" <jbrigan@yahoo.com> wrote in message news:OxJG8Hu2IHA.5024@TK2MSFTNGP03.phx.gbl... > How would I do this: > > I have a server with a drive letter mapped to F: > I need to copy some of the folders from F: to an existing folder on drive > T:, which is on another server. > Say the folder names on F: are Folder1 and Folder2. (there's actually > about 10 folders) > I want to copy Folder1 and Folder2 to drive T: > How can I copy Folder1 and all it's sub-contents to T: without first > creating a folder in the existing folder on T: > I want to avoid, if possible, doing a: MD t:\Folder1 and copying the > contents of F:\Folder1 > In other words, I want the copy, or in this case, xcopy, command to create > the folder name for me. > > Is there a way to do that? > > TIA > Have a look at "xcopy.exe /?". It tells you which switches to use to create a target folder on the fly.
Guest JohnB Posted June 30, 2008 Posted June 30, 2008 Re: Another batch file question I see the /T switch, which "Creates the Directory Structure". But it says it does not copy files. What would I have to do, use the xcopy command with the /T switch, then follow that with another xcopy command that actually does the copying? "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message news:%23Ty$Rpu2IHA.1196@TK2MSFTNGP05.phx.gbl... > > "JohnB" <jbrigan@yahoo.com> wrote in message > news:OxJG8Hu2IHA.5024@TK2MSFTNGP03.phx.gbl... >> How would I do this: >> >> I have a server with a drive letter mapped to F: >> I need to copy some of the folders from F: to an existing folder on drive >> T:, which is on another server. >> Say the folder names on F: are Folder1 and Folder2. (there's actually >> about 10 folders) >> I want to copy Folder1 and Folder2 to drive T: >> How can I copy Folder1 and all it's sub-contents to T: without first >> creating a folder in the existing folder on T: >> I want to avoid, if possible, doing a: MD t:\Folder1 and copying the >> contents of F:\Folder1 >> In other words, I want the copy, or in this case, xcopy, command to >> create the folder name for me. >> >> Is there a way to do that? >> >> TIA >> > > Have a look at "xcopy.exe /?". It tells you which switches to use > to create a target folder on the fly. >
Guest Pegasus \(MVP\) Posted June 30, 2008 Posted June 30, 2008 Re: Another batch file question A few quick tests with xcopy.exe would show you that you can do almost anything with this command. Did you try the /I switch? "JohnB" <jbrigan@yahoo.com> wrote in message news:utwi4tu2IHA.2060@TK2MSFTNGP02.phx.gbl... >I see the /T switch, which "Creates the Directory Structure". But it says >it does not copy files. > > What would I have to do, use the xcopy command with the /T switch, then > follow that with another xcopy command that actually does the copying? > > > > "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message > news:%23Ty$Rpu2IHA.1196@TK2MSFTNGP05.phx.gbl... >> >> "JohnB" <jbrigan@yahoo.com> wrote in message >> news:OxJG8Hu2IHA.5024@TK2MSFTNGP03.phx.gbl... >>> How would I do this: >>> >>> I have a server with a drive letter mapped to F: >>> I need to copy some of the folders from F: to an existing folder on >>> drive T:, which is on another server. >>> Say the folder names on F: are Folder1 and Folder2. (there's actually >>> about 10 folders) >>> I want to copy Folder1 and Folder2 to drive T: >>> How can I copy Folder1 and all it's sub-contents to T: without first >>> creating a folder in the existing folder on T: >>> I want to avoid, if possible, doing a: MD t:\Folder1 and copying the >>> contents of F:\Folder1 >>> In other words, I want the copy, or in this case, xcopy, command to >>> create the folder name for me. >>> >>> Is there a way to do that? >>> >>> TIA >>> >> >> Have a look at "xcopy.exe /?". It tells you which switches to use >> to create a target folder on the fly. >> >
Guest JohnB Posted June 30, 2008 Posted June 30, 2008 Re: Another batch file question I hadn't tried the /I switch..... but I just did. Here's the command I'm using in a batch file. MD t:\%date:~4,2%%date:~7,2%%date:~-2% xcopy f:\testing\*.* t:\%date:~4,2%%date:~7,2%%date:~-2% /S /E /I I create the folder first, named from the current date. Then I need to copy a folder (Testing) from F: to that newly created folder. All I get on T: is the sub-contents of F:\testing It doesn't create the folder TESTING on the fly "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message news:%23ddqM9u2IHA.2332@TK2MSFTNGP03.phx.gbl... >A few quick tests with xcopy.exe would show you that > you can do almost anything with this command. Did you > try the /I switch? > > "JohnB" <jbrigan@yahoo.com> wrote in message > news:utwi4tu2IHA.2060@TK2MSFTNGP02.phx.gbl... >>I see the /T switch, which "Creates the Directory Structure". But it says >>it does not copy files. >> >> What would I have to do, use the xcopy command with the /T switch, then >> follow that with another xcopy command that actually does the copying? >> >> >> >> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message >> news:%23Ty$Rpu2IHA.1196@TK2MSFTNGP05.phx.gbl... >>> >>> "JohnB" <jbrigan@yahoo.com> wrote in message >>> news:OxJG8Hu2IHA.5024@TK2MSFTNGP03.phx.gbl... >>>> How would I do this: >>>> >>>> I have a server with a drive letter mapped to F: >>>> I need to copy some of the folders from F: to an existing folder on >>>> drive T:, which is on another server. >>>> Say the folder names on F: are Folder1 and Folder2. (there's actually >>>> about 10 folders) >>>> I want to copy Folder1 and Folder2 to drive T: >>>> How can I copy Folder1 and all it's sub-contents to T: without first >>>> creating a folder in the existing folder on T: >>>> I want to avoid, if possible, doing a: MD t:\Folder1 and copying the >>>> contents of F:\Folder1 >>>> In other words, I want the copy, or in this case, xcopy, command to >>>> create the folder name for me. >>>> >>>> Is there a way to do that? >>>> >>>> TIA >>>> >>> >>> Have a look at "xcopy.exe /?". It tells you which switches to use >>> to create a target folder on the fly. >>> >> > >
Guest Pegasus \(MVP\) Posted June 30, 2008 Posted June 30, 2008 Re: Another batch file question "JohnB" <jbrigan@yahoo.com> wrote in message news:%23NyJZUv2IHA.4164@TK2MSFTNGP03.phx.gbl... >I hadn't tried the /I switch..... but I just did. > > Here's the command I'm using in a batch file. > > MD t:\%date:~4,2%%date:~7,2%%date:~-2% > xcopy f:\testing\*.* t:\%date:~4,2%%date:~7,2%%date:~-2% /S /E /I > > I create the folder first, named from the current date. > Then I need to copy a folder (Testing) from F: to that newly created > folder. > All I get on T: is the sub-contents of F:\testing > It doesn't create the folder TESTING on the fly I would have been very surprised if your command had created the folder "testing", since you're copying the ***contents*** of the "testing" folder, not the folder itself. It's like saying "give me the contents of your wallet" or "give me your wallet". Not the same at all! Also: why the belts and braces approach? The /I switch will create the destination folder, so why create it manually too? Have a look at the other switches below. They are essential when operating the command in a batch file. set MyDate=%date:~4,2%%date:~7,2%%date:~-2% xcopy /s /e /i /y /d f:\testing "t:\%MyDate%\Testing"
Guest JohnB Posted July 1, 2008 Posted July 1, 2008 Re: Another batch file question Worked like a charm!! Thank you. > Also: why the belts and braces approach? Haven't played with this enough. It's a cludge of a backup but, it's what they wanted. "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message news:eueqbnv2IHA.3544@TK2MSFTNGP05.phx.gbl... > > "JohnB" <jbrigan@yahoo.com> wrote in message > news:%23NyJZUv2IHA.4164@TK2MSFTNGP03.phx.gbl... >>I hadn't tried the /I switch..... but I just did. >> >> Here's the command I'm using in a batch file. >> >> MD t:\%date:~4,2%%date:~7,2%%date:~-2% >> xcopy f:\testing\*.* t:\%date:~4,2%%date:~7,2%%date:~-2% /S /E /I >> >> I create the folder first, named from the current date. >> Then I need to copy a folder (Testing) from F: to that newly created >> folder. >> All I get on T: is the sub-contents of F:\testing >> It doesn't create the folder TESTING on the fly > > I would have been very surprised if your command had > created the folder "testing", since you're copying the > ***contents*** of the "testing" folder, not the folder > itself. It's like saying "give me the contents of your > wallet" or "give me your wallet". Not the same at all! > > Also: why the belts and braces approach? The /I switch > will create the destination folder, so why create it > manually too? > > Have a look at the other switches below. They are essential > when operating the command in a batch file. > > set MyDate=%date:~4,2%%date:~7,2%%date:~-2% > xcopy /s /e /i /y /d f:\testing "t:\%MyDate%\Testing" > >
Guest Pegasus \(MVP\) Posted July 1, 2008 Posted July 1, 2008 Re: Another batch file question Thanks for the feedback. "JohnB" <jbrigan@yahoo.com> wrote in message news:ehJ7GQ32IHA.1420@TK2MSFTNGP06.phx.gbl... > Worked like a charm!! > Thank you. > >> Also: why the belts and braces approach? > Haven't played with this enough. > > It's a cludge of a backup but, it's what they wanted.
Recommended Posts