Page 1 of 1
Very Odd - Copied File Shows Immediately, Windows Stays Open
Posted: 06 Nov 2012 12:28
by accesshawaii
I have a real basic copy command, which is below
copy "N:\Network Folder\Some Data\TheDatabase.accdb" "C:\Development\BackEnd"
When I run this, what happens is the file shows up immediately in the "BackEnd" folder with the full file size. If I try to open it, I get a "File already in use" error, which I'm assuming is because it's not fully copied.
When I've been running this before, the file size of the copied file would keep growing. Everytime, I refreshed, the size would show as larger. This was good because I knew that it was copying. With this, the DOS window stays open with the below text
C:\MyFolder copy "N:\Network Folder\Some Data\TheDatabase.accdb" "C:\Development\BackEnd"
MyFolder is where I am running the batch file from. Does anyone know why it's doing it this way now? Also, is it actually doing something? The file normally takes about 45 minutes to copy over but I don't want to sit here and wait if it's not actually doing anything.
Any assistance would be appreciated.
Re: Very Odd - Copied File Shows Immediately, Windows Stays
Posted: 06 Nov 2012 14:33
by Boombox
.
copy /Z c:\test.mkv d:\test.mkv
This will give you a percentage indicator for the file you are copying.
Re: Very Odd - Copied File Shows Immediately, Windows Stays
Posted: 06 Nov 2012 21:48
by foxidrive
accesshawaii wrote:Does anyone know why it's doing it this way now?
FWIW That behaviour is normal on a network I think. The date and time stamp will not be correct though.
In later versions of Windows, on local drives, it stays at 0 bytes until finished (except for cases when the folder is updated by another process when you will get the partial filesize).
Re: Very Odd - Copied File Shows Immediately, Windows Stays
Posted: 07 Nov 2012 08:12
by accesshawaii
Got it worked out. Thanks.
Another question, if you don't mind. I have done this before but cannot remember how exactly I did it. What I'm trying to do is check if a folder exists on a machine and if it doesen't then create a folder as well as sub-folders. The pseudo code would be something like the below.
If Not Exist C:\MyFolder Then
Make Folder C:\MyFolder
Make Folder C:\MyFolder\Items
Make Folder C:\MyFolder\Notes
Make Folder C:\MyFolder\Notes\Responses
Any assistance on how to do this would be appreciated. Thanks again.
Re: Very Odd - Copied File Shows Immediately, Windows Stays
Posted: 07 Nov 2012 08:24
by Boombox
.
IF NOT EXIST C:\MyFolder\Notes\Responses MD C:\MyFolder\Notes\Responses
Even if none of the folders exist, Myfolder, Notes and Responses, will all be built.
MD = Make Directory
Re: Very Odd - Copied File Shows Immediately, Windows Stays
Posted: 07 Nov 2012 08:38
by accesshawaii
That's what I needed. Thanks again.
Re: Very Odd - Copied File Shows Immediately, Windows Stays
Posted: 07 Nov 2012 08:48
by foxidrive
Boombox wrote:.
IF NOT EXIST C:\MyFolder\Notes\Responses MD C:\MyFolder\Notes\Responses
Even if none of the folders exist, Myfolder, Notes and Responses, will all be built.
MD = Make Directory
You could do this - note that the trailing backslash is required for reliable testing of the existence of a folder.
if not exist "c:\myfolder\" md "C:\MyFolder\Notes\Responses"
Or just use this where the harmless error messages will be sent to nul.
MD "C:\MyFolder\Items" 2>nul
MD "C:\MyFolder\Notes\Responses" 2>nul
Re: Very Odd - Copied File Shows Immediately, Windows Stays
Posted: 07 Nov 2012 09:17
by accesshawaii
Yet, another question
. I'm almost done though. I'm just trying copy an entire folder and its contents, for example if I have the folder R:\MyFolder, I just want to copy that to C:\Local\MyFolder. Something that I thought would be eash but have not been able to figure it out. Below is the syntax that I'm using.
xcopy /s "R:\MyFolder\*.*" "C:\Local\MyFolder"
It's copying the contents of the folder but not the folder. I need the actual folder and its contents included. What am I doing wrong?
I do appreciate all the help.
Re: Very Odd - Copied File Shows Immediately, Windows Stays
Posted: 07 Nov 2012 10:12
by Boombox
.
This worked for me...
Code: Select all
xcopy R:\MyFolder C:\Local\MyFolder\ /e
You can use
/y at the end too, this will overwrite existing files without prompt.
Type
xcopy /? at CMD for help
Re: Very Odd - Copied File Shows Immediately, Windows Stays
Posted: 07 Nov 2012 10:27
by foxidrive
accesshawaii wrote:xcopy /s "R:\MyFolder\*.*" "C:\Local\MyFolder"
It's copying the contents of the folder but not the folder. I need the actual folder and its contents included. What am I doing wrong?
Do you want this:
"C:\Local\MyFolder\MyFolder"