Command Prompt - Transferring Files

April 29, 2008 at 05:06:24
Specs: Windows XP Professio, AMD 64 --1GB Tam
I want to create a batch file (utilizing the command prompt) that would go to 1 drive, copy the contents of a folder within that drive. Then go to another drive, delete the contents of a folder there and replace (copy) the files from drive 1 into it.

I've read a few command prompt tutorials, but haven't come across how to copy files over like this. Is there one out there? I know this is simple, but things are always hard until you learn how to do them!

Thanks,

"No matter how hard you try, you can't baptize cats."


See More: Command Prompt - Transferring Files

Report •


#1
April 29, 2008 at 05:12:30
Use the following command in a batch file.

C:\move /
Moves files and renames files and directories.

To move one or more files:
MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination

To rename a directory:
MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2

[drive:][path]filename1 Specifies the location and name of the file
or files you want to move.
destination Specifies the new location of the file. Destination
can consist of a drive letter and colon, a
directory name, or a combination. If you are moving
only one file, you can also include a filename if
you want to rename the file when you move it.
[drive:][path]dirname1 Specifies the directory you want to rename.
dirname2 Specifies the new name of the directory.

/Y Suppresses prompting to confirm you want to
overwrite an existing destination file.
/-Y Causes prompting to confirm you want to overwrite
an existing destination file.

The switch /Y may be present in the COPYCMD environment variable.
This may be overridden with /-Y on the command line. Default is
to prompt on overwrites unless MOVE command is being executed from
within a batch script.

one time, some time, all the time...All about the past moment


Report •

#2
April 30, 2008 at 12:16:35
Move doesn't fit the OP's criteria

rem #first establish drive maps
net use x: \\pc1\sharename\folder1
net use y: \\pc2\sharename\folder2

rem #now you delete the contents
y:
delete *.* /y

rem #now you copy the contents of folder1 to folder2 [/s is for subfolders if they exist]
xcopy x:\*.* /s

exit

Imagine the power of knowing how to internet search
http://www.lib.berkeley.edu/Teachin...


Report •

#3
May 1, 2008 at 04:46:51
Looks like you have the solution right there; except for destination directory in xcopy command line...
1. Why do you need to delete all of the contents of Y:\?

2. Is the data from X:\ newer versions of data from Y:\?

3. What errors are you getting when you run the command?

one time, some time, all the time...All about the past moment


Report •

Related Solutions

#4
May 2, 2008 at 04:22:56
I work in an office environment and we use many web favorites. However, the auto-start on each PC is set to a specific format that resets our Favorites every morning when we log in. So I wanted to create a batch file I could throw in the start-up that would automatically delete the useless favorites (about 40) and replace them with our department specific favorites (about 10) to be more organized.

"No matter how hard you try, you can't baptize cats."


Report •

#5
May 2, 2008 at 05:39:00
Xcopy will definately work I did not read all of your criteria...
If you have your favorites folder stored locally or on a shared drive you could just change the path to your users favorites folder in the registry to always read your favorites folder.

In the registry:

My Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

Edit the Favorites entry to point to where your favorites location is.

one time, some time, all the time...All about the past moment


Report •

#6
May 2, 2008 at 07:48:25
that would be MUCH better! However, our computers are locked down tight. I cannot run the command prompt to run "RegEdit". Is there another way to modify my registry. I REALLY appreciate your help!!!

"No matter how hard you try, you can't baptize cats."


Report •

#7
May 2, 2008 at 08:12:25
"except for destination directory in xcopy command line..."

timexed you don't need a distination because by default it will copy to the present location which in this case is y:

McRibisBack if that is all you want to do is edit favorites why not talk to your IT dept? Surely they can help.

Imagine the power of knowing how to internet search
http://www.lib.berkeley.edu/Teachin...


Report •

#8
May 2, 2008 at 08:32:02
Well, I work for a bank and our profiles are all under the same umbrella, which totals around 10,000 associates. So to ask them to do so would mean they would have to do it for all the LOBs and they weren't to keep on the idea. So, I was going to make a batch file and toss it in the start-up so our group can at least have what they need.

"No matter how hard you try, you can't baptize cats."


Report •

#9
May 4, 2008 at 05:13:03
"except for destination directory in xcopy command line..."

Thank you wanderer; I mispoke, after I went back and read some notes I realized the mistake. As for fixing the registry when you don't have acess to the command prompt. You can create the change on your computer and export the key and save it as a .reg file. After you make the change right click on the User Shell Folders and Export save to location as .reg file. Bring this registry file to work and double click on it. It will change only that entry on your computer. If your locked down too much you might not have access to change the registry as a domain user.

one time, some time, all the time...All about the past moment


Report •


Ask Question