0

I would like to make a .bat file which will make a backup for my kdbx file. I have two simple commands there.

cd C://Access
xcopy access4.kdbx access4.backup.kdbx /Y

but the second one ask me: Does access4.backup.kdbx specify a file name or directory name on the target (F = file, D = directory)?

I dont understand why Windows does not recognize the file in the source. Also I don't see any option to set it up in the command. How can I solve it?

Čamo
  • 3,863
  • 13
  • 62
  • 114

2 Answers2

3

You are mixing simple and multiple copying of files:

xcopy is to be used for copying multiple files.

copy is to be used for copying just one file.

So, your command should be:

copy /Y access4.kdbx access4.backup.kdbx
Dominique
  • 16,450
  • 15
  • 56
  • 112
1

To begin with, the Windows path separator is \ but not / or //.

Then you should use cd /D rather than plain cd since you specified also a drive letter.


The quick solution is to use copy rather than xcopy, because it does not show such a prompt:

cd /D "C:\Access"
copy /Y "access4.kdbx" "access4.backup.kdbx"

However, xcopy features a lot of additional options in contrast to copy, so the latter might not help in certain situations.


To avoid the prompt, you could pre-create the destination file and let xcopy overwrite it:

cd /D "C:\Access"
>> "access4.backup.kdbx" rem/
xcopy /Y "access4.kdbx" "access4.backup.kdbx"

See also this answer.

aschipfl
  • 33,626
  • 12
  • 54
  • 99