Very Odd - Copied File Shows Immediately, Windows Stays Open

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
accesshawaii
Posts: 12
Joined: 01 Nov 2012 09:19

Very Odd - Copied File Shows Immediately, Windows Stays Open

#1 Post by accesshawaii » 06 Nov 2012 12:28

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.

Boombox
Posts: 80
Joined: 18 Oct 2012 05:51

Re: Very Odd - Copied File Shows Immediately, Windows Stays

#2 Post by Boombox » 06 Nov 2012 14:33

.
copy /Z c:\test.mkv d:\test.mkv

This will give you a percentage indicator for the file you are copying.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Very Odd - Copied File Shows Immediately, Windows Stays

#3 Post by foxidrive » 06 Nov 2012 21:48

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).

accesshawaii
Posts: 12
Joined: 01 Nov 2012 09:19

Re: Very Odd - Copied File Shows Immediately, Windows Stays

#4 Post by accesshawaii » 07 Nov 2012 08:12

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.

Boombox
Posts: 80
Joined: 18 Oct 2012 05:51

Re: Very Odd - Copied File Shows Immediately, Windows Stays

#5 Post by Boombox » 07 Nov 2012 08:24

.
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

accesshawaii
Posts: 12
Joined: 01 Nov 2012 09:19

Re: Very Odd - Copied File Shows Immediately, Windows Stays

#6 Post by accesshawaii » 07 Nov 2012 08:38

That's what I needed. Thanks again.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Very Odd - Copied File Shows Immediately, Windows Stays

#7 Post by foxidrive » 07 Nov 2012 08:48

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

accesshawaii
Posts: 12
Joined: 01 Nov 2012 09:19

Re: Very Odd - Copied File Shows Immediately, Windows Stays

#8 Post by accesshawaii » 07 Nov 2012 09:17

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.

Boombox
Posts: 80
Joined: 18 Oct 2012 05:51

Re: Very Odd - Copied File Shows Immediately, Windows Stays

#9 Post by Boombox » 07 Nov 2012 10:12

.
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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Very Odd - Copied File Shows Immediately, Windows Stays

#10 Post by foxidrive » 07 Nov 2012 10:27

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"

Post Reply