lsteinme
lsteinme

Reputation: 750

Xcopy does not copy all files

I wrote a tool for our department that generates a protocol from an Atlassian Datasource.
Because in some cases the tool didn't worked when started from the company's netdrive, a colleague wrote the following batch file to simply copy the relevant files locally, which lead to a working program for all.

mkdir C:\QuickProtocol\
mkdir C:\QuickProtocol\Templates\
mkdir C:\QuickProtocol\In\
mkdir C:\QuickProtocol\Out\
mkdir C:\QuickProtocol\Templates\Protokoll-Dateien\

XCOPY \\*NetDrivePath*\QuickProtocol.exe  C:\QuickProtocol\ /y 
XCOPY \\*NetDrivePath*\QuickProtocol.pdb  C:\QuickProtocol\ /d /y 
XCOPY \\*NetDrivePath*\Languages.xml      C:\QuickProtocol\ /d /y 
XCOPY \\*NetDrivePath*\PrimeCore.dll      C:\QuickProtocol\ /d /y 
XCOPY \\*NetDrivePath*\Templates          C:\QuickProtocol\Templates\ /d /y /s 

But now a colleague that changed departments, but has still access to the files on the netdrive, tried the batch file again.
Strangely in his case, as well as in the case of some other colleagues who reported to him, the batch file only copy's the Templates Folder and creates the directories named above.
What could be the reason for this?

Upvotes: 5

Views: 13201

Answers (4)

hellorayza
hellorayza

Reputation: 75

I have similar question:

xcopy copied incompelete,does not copy all files, some directory and file lose.

I know some reason may cause that:

1.directory character string too long ,but it's no more than 100 for mine;

2.hide directory default not execute copy , unless use /H. I use this params and it's not hide directory.

3.I have checked directory permission

So I was very curious about why.

Some feelings:

xcopy has no question log, I have no idea what's going on, why can't he handle it.

finnally:

I use robocopy instead of xcopy

Upvotes: 0

Mofi
Mofi

Reputation: 49186

The reason for failure on copying of the files could be missing permissions to read the contents of the files.

The Microsoft documentation about Permissions for files and folders explains in details the possible permissions on NTFS drives. The Microsoft documentation How permissions are handled when you copy and move files and folders describes how Windows Explorer handles file and folder permissions in different situations.

It is possible that users have only Traverse Folder/List Folder permissions which means they can view which subfolders and files are in a folder and browse also to subfolders. In other words the users have the permissions to list the directory tree.

But if the users have not additionally the Read Data permission, they can't open a file for reading. In this case also copy and xcopy fail to copy the files as of no permission to read the data of a file.

It is possible that running the application directly from shared network folder failed because of same reason. The users have permissions to Traverse Folder/List Folder/Execute File, but no permissions for Read Data and therefore the application failed to read the files in the directory.

I suggest that one of the users having trouble should try to open the file Languages.xml in Notepad or in Internet Explorer directly from the shared network folder. An error message is shown by those applications if the user does not have the required Read Data permission.

It could be also helpful to append to the batch file at bottom the command Pause, change @echo off at top of the batch file to @echo on if that line exists at all, and then execute the batch file. Now the user can view the executed commands and also all errors occurring during batch file execution.

Upvotes: 3

Marlon
Marlon

Reputation: 1897

Because of permission errors I used robocopy instead of copy or xcopy

More info here:

Exclude folders in batch-copy-script

Upvotes: 0

lsteinme
lsteinme

Reputation: 750

Thanks for all the answers, in my case changing Xcopy to Copy for the few single file Copys helped, at least it seems so. Hopefully it stays this way^^

Upvotes: 2

Related Questions