Windows – Copying files in Windows 7 command line – The System cannot find the file specified

cmd.exewindows 7

I know this is a stupid question I've made batch files for years and haven't had this much trouble… I'm trying to make a batch file to copy files into a folder and for the life of me I can't get it to work.

cd C:\Program Files (x86)\Steam\SteamApps\common\Skyrim\Data\
copy FifthGenerationMage.bsa C:\Users\Mark Collins\Desktop\DATA
copy FifthGenerationMage.bsl C:\Users\Mark Collins\Desktop\DATA
copy FifthGenerationMage.ckm C:\Users\Mark Collins\Desktop\DATA
copy FifthGenerationMage.esp C:\Users\Mark Collins\Desktop\DATA
pause

This should work, right? Copy , right? When I do it like this, it says the syntax is incorrect.

When I do this:

copy C:\Program Files (x86)\Steam\SteamApps\common\Skyrim\Data\FifthGenerationMage.bsa C:\Users\Mark Collins\Desktop\DATA
copy C:\Program Files (x86)\Steam\SteamApps\common\Skyrim\Data\FifthGenerationMage.bsl C:\Users\Mark Collins\Desktop\DATA
copy C:\Program Files (x86)\Steam\SteamApps\common\Skyrim\Data\FifthGenerationMage.ckm C:\Users\Mark Collins\Desktop\DATA
copy C:\Program Files (x86)\Steam\SteamApps\common\Skyrim\Data\FifthGenerationMage.esp C:\Users\Mark Collins\Desktop\DATA

It says "The System cannot find the file specified."

Both of those should work. I don't get it.

Best Answer

If your path contains spaces - you have to enclose whole path with ", like this:

copy "C:\Program Files (x86)\...\FifthGenerationMage.bsa" "C:\Users\...\DATA"

I would also suggest to use variable to store target path and simplify script:

set skyrimdata="C:\Program Files (x86)\Steam\SteamApps\common\Skyrim\Data"
set target="C:\Users\Mark Collins\Desktop\DATA"

copy "%skyrimdata%\FifthGenerationMage.bsa" %target%
copy "%skyrimdata%\FifthGenerationMage.bsl" %target%
copy "%skyrimdata%\FifthGenerationMage.ckm" %target%
copy "%skyrimdata%\FifthGenerationMage.esp" %target%

Why it doesnt work?

Look:

|     | 1         | 2    | 3               | 4      |5      |
 copy   C:\Folder   with   spaces\file.txt   E:\Some folder

System reads it as:

1 - parameter 1 (for copy command - source 1)

2 - parameter 2 (for copy command - source 2)

3 - parameter 3 (for copy command - source 3)

4 - parameter 4 (for copy command - source 4)

5 - parameter 5 (for copy command - target)

There are no C:\Folder, with, spaces\file.txt files or directories - and you get error:

The System cannot find the file specified.

Related Question