Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch file

Status
Not open for further replies.

Mungovan

Programmer
Oct 24, 2002
94
IE
Hi.
Basically this is my boggle:

I have access to both the C: and N: drives. In a folder in the N: drives there's a number of Excel files. More Excel files are being added each day to this folder on the N: drive.

Basically I need to create a .bat file that does the following task:

Makes a copy of the Excel files on the N: drive in folder Import and pastes them to a folder called Import on the C: drive. Grand. But the trick is that I wan't it to check wether the files being copied/pasted from the N: drive to the C: drive are already on the C: drive in folder Import. If they are, then don't copy/paste them. Only copy and paste the Excel files that are new on the N: drive.

Anyway I hope I kinda explained myself half decent and hope that someone can help me with those commands????


Thanks a million,
D
 
if overwriting the exsiting files doesn't upsets you :), try
xcopy n:\import\*.xls c:\import\ /c


try: xcopy /?| more
for help
 
if u really don't want to overwrite the existing files:

attrib c:\import\*.xls +r
xcopy n:\import\*.xls c:\import\ /c
attrib c:\import\*.xls -r

[pc3]
 
Hi!
Thanks for the help.

But it's not working. I'm only using the line:

xcopy n:\Dept\BG CoGen\Import\* c:\import\ /c

But it's saying that : "Invalid number of parameters specified."

Do you know what I can do????

Thanks,
D
 
LOL
u never used DOS before :)
no longnames native support :)))
try this :

xcopy "n:\Dept\BG CoGen\Import\*" c:\import\ /c
 
Hi.
I did that " inverted commas" thing and now the code is running fine. But the
attrib c:\import\*.xls +r
line gives an error "File not found - C:\import\*.xls"

I was thinking of a different way though:
Is there a way to loop through all the entries in a file and say something like:

File [x]
IF EXISTS (in C:) then don't copy and paste, otherwise copy and paste to C: drive.

x++

Or something to that effect????

Anyway,
Thanks for all you help,
D

 
attrib is only to protect the existing xls files (if any), it sets them read-only
ms-dos prompt ain't too powerful ... (linux is)
you can make a delphi program to do this task easily
 
Wait!

I changed it to *.* and it seems to be working now!

Thanks!
D
 
try in a command prompt window
attrib /?
xcopy /?
for more options
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top