Don-White
asked on
copy with command line does not copy the complete file
Attached is my code and it will work on a small file, but the Access file which is large will not copy the complete file.
I am using a bat file and then using the Task Scheduler to execute the backup on a schedule.
I there a better way to backup a single file auto based on a time frame?
This is my code: copy c:\WorkKeys.mdb+\*%date:~4 ,2%%date:~ 7,2% f:
I am using a bat file and then using the Task Scheduler to execute the backup on a schedule.
I there a better way to backup a single file auto based on a time frame?
This is my code: copy c:\WorkKeys.mdb+\*%date:~4
Is the database in use while the backup is in operation?
That would definately cause the copy to fail
You could try copying the file to the same directory first and then copy it to the other directory
But if any part of the database changes during the copy it WILL fail
That would definately cause the copy to fail
You could try copying the file to the same directory first and then copy it to the other directory
But if any part of the database changes during the copy it WILL fail
ASKER
This is the code. It only copies 8kb not the complete access file.
copy c:\WorkKeys.mdb+\*%date:~4 ,2%%date:~ 7,2% f:\WorkKeys.mdb
copy c:\WorkKeys.mdb+\*%date:~4
Try using the BINARY switch /B...
Database files can have all sorts of odd characters in them, and one of them could be being interpreted as a false End Of File marker.
The /B switch will solve this.
Database files can have all sorts of odd characters in them, and one of them could be being interpreted as a false End Of File marker.
The /B switch will solve this.
ASKER
The db is not in use.
I tried this and it only copied 8 kb not complete file.
copy c:\WorkKeys.mdb+\*%date:~4 ,2%%date:~ 7,2% /b f:\WorkKeys.mdb
I tried this and it only copied 8 kb not complete file.
copy c:\WorkKeys.mdb+\*%date:~4
Silly question...
What is the SOURCE file called? (my guess is WorkKeys.mdb).
Where is the SOURCE file? (My guess is C:\)
Where are you trying to copy it to? (My guess is F:\)
What are you trying to do with the Date info? (I cannot figure out!)
If you type "Copy C:\WorkKeys.mdb F:\WorkKeys.mdb /B" does it work?
What is the SOURCE file called? (my guess is WorkKeys.mdb).
Where is the SOURCE file? (My guess is C:\)
Where are you trying to copy it to? (My guess is F:\)
What are you trying to do with the Date info? (I cannot figure out!)
If you type "Copy C:\WorkKeys.mdb F:\WorkKeys.mdb /B" does it work?
Reason I ask is that I get a syntax error when trying your command line!
ASKER
My code works OK except it does not copy the whole file
I want the file in drive F to have the current date and not the date of the copied file.
You assumptions are correct.
Is there a better way to do what I need to do?
I want the file in drive F to have the current date and not the date of the copied file.
You assumptions are correct.
Is there a better way to do what I need to do?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Exactly what file(s) are you trying to copy? The syntax you are using with a + in the middle of the first COPY command parameter normally indicates you want to concatenate two (or more) files together. But if the first of those is an MDB as you show then I don't understand why you would want to join other files onto that MDB file in the destination? Can you describe what you need to do?
~bp
~bp
ASKER
I tried it and it worked, but left the command lines on the desktop. How to clear that?
Attached is the screen
Screen.docx
Attached is the screen
Screen.docx
ASKER
It did work and finally the command line closed when the file was completely copied. Thanks, for your excellent help and Merry Christmas and a Happy New Year.
Don
Don
Nothing for the fact that you were missing the /B...
<sigh>
<sigh>
Well, you have to put a BAT file in some folder not on the Desktop.!!!
And you know how to execute a BAT file with a Task Scheduler.
You choose a time when you want to copy that MDB file.
And in a case that MDB file already exists in the F:\ you need to add a /Y switch in a command line.
It doesn't ask then do you want to overwrite the old WorkKeys.mdb file in the F: root.
So, the command look like:
copy /B /Y c:\WorkKeys.mdb+\*%date:~4
Nrisimha
ASKER
I want to keep multicopies in the f drive. How do I do that?
I know the question is closed, and I may be missing something, but I'm still concerned that Don-White may not be getting what he wants. The way the command is written it will do the following:
Concatenate the file C:\WorkKeys.mdb with any other files in the root of the current directory (likely C:\) that start with anything and contain 1219 in their file name. This single concatenated file will be copied to the file F:\WorkKeys.mdb.
This doesn't feel like anything useful, and appears that the date logic is not affecting the copy at all, and the result is the same as:
copy C:\WorkKeys.mdb F:\WorkKeys.mdb
~bp
Concatenate the file C:\WorkKeys.mdb with any other files in the root of the current directory (likely C:\) that start with anything and contain 1219 in their file name. This single concatenated file will be copied to the file F:\WorkKeys.mdb.
This doesn't feel like anything useful, and appears that the date logic is not affecting the copy at all, and the result is the same as:
copy C:\WorkKeys.mdb F:\WorkKeys.mdb
~bp
This doesn't feel like anything useful, and appears that the date logic is not affecting the copy at all, and the result is the same as:
copy C:\WorkKeys.mdb F:\WorkKeys.mdb
Of course it is not the same, because your command copy C:\WorkKeys.mdb F:\WorkKeys.mdb will copy a file WorkKeys.mdb from the C:\ to F:\, but will have ORIGINAL date of input file on C:\ !!!
But, Don-White want to copy C:\WorkKeys.mdb file with a date taken in the moment of copying this file !!!
But, why didn't you try first that command from CLI and then you could see these differences:
Original file
After copying with command copy /Y C:\WorkKeys.mdb F:\WorkKeys.mdb:
The date is the SAME !!!
And now, copying with command copy /B /Y c:\WorkKeys.mdb+\*%date:~4
The original file on C:\ is the same.
After copying with above code copy /B /Y c:\WorkKeys.mdb+\*%date:~4
regards
Nrisimha
Okay, if that was indeed the intention (not sure I saw that stated anyplace), then a preferred approach would be:
~bp
command copy /B /Y c:\WorkKeys.mdb+nul f:\WorkKeys.mdb
orcommand copy /B /Y c:\WorkKeys.mdb+,, f:\WorkKeys.mdb
these accomplish that task, and don't confuse things by referencing nonexistent files with the %DATE% variable.~bp
This is move how you need to write it up. You need to include the file extension and also need to retype the file name in the directory you want to place the file.