xcopy comes up with 'file not found'


  1. Posts : 21
    Windows 7 Home Premium 64bit
       #1

    xcopy comes up with 'file not found'


    I am just trying to get this simple script i wrote to work in a batch file, but when I run the file, in the cmd screen, it comes up with;

    File not found- Backup
    0 file(s) copied

    This is the script I use;

    @Echo Off

    xcopy /s "c:\Users\Jacob Smith\Desktop\Server\world d:\Users\Jacob Smith\Desktop\Server\World Save"

    I think the problem is in the path (Derp) or the commands (Most likely the way i format the path). Please help, I'm just trying to do this so I can auto-backup a server.

    btw, I am a command script-newb but I understand the basics, and I learn easy.
      My Computer


  2. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #2

    Hi Jake, welcome to the Seven Forums.

    You have a simple syntax error. As you know, because you have spaces on path name (for instance your user folder Jacob Smith), you need to put the path between quotation marks. As you only have one quotation mark in the beginning of the source path but no end quotation mark, and respectively no quotation mark in the beginning of the target path, only one at the end of it, Windows logically thinks that "c:\Users\Jacob Smith\Desktop\Server\world d:\Users\Jacob Smith\Desktop\Server\World Save" is one (the source) path statement and when it can not find target path it produces an error message.

    Change the paths syntax like this:
    "c:\Users\Jacob Smith\Desktop\Server\world" "d:\Users\Jacob Smith\Desktop\Server\World Save"
    (Blue = Source Path, Red = Target Path, Green = Missing Quotation marks)

    Kari
      My Computer


  3. Posts : 21
    Windows 7 Home Premium 64bit
    Thread Starter
       #3

    I did that earlier, and i just tested again, but it comes up with;

    Invalid Drive Specification
    0 File(s) copied

    Im guessing theres two problems then, but it first run into the path one. I don't even know I was specifying a drive.

    Btw the cmd window closes less than a second after I run the batch, so some parts of the results may be a bit inaccurate, I have gotten them right so far though.
      My Computer


  4. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #4

    OK.

    Your XCOPY statement has two paths, source and target. Both of them seem to be so called full paths i.e. including a drive, followed by mainfolder and subfolders.

    Now check that the paths exist. First source: are you copying from C: drive's Users\Jacob Smith\Desktop\Server\world to D: drive's Users\Jacob Smith\Desktop\Server\World Save?

    Next, your source path does not tell what to copy. Wildcard *.* copies all files on source folder but no subfolders and files on those, parameter /s copies also subfolders and files on those (except empty subfolders), and parameter /e also the empty subfolders.

    Examples using your source and target paths:
    - copy all files from source folder but no subfolders nor files on subfolders:
    XCOPY "C:\Users\Jacob Smith\Desktop\Server\World\*.*" "D:\Users\Jacob Smith\Desktop\Server\World Save\"

    - copy all files from source folder including subfolders but no empty subfolders:
    XCOPY "C:\Users\Jacob Smith\Desktop\Server\World\*.*" /s "D:\Users\Jacob Smith\Desktop\Server\World Save\"

    - copy all files from source folder including subfolders, also empty subfolders:
    XCOPY "C:\Users\Jacob Smith\Desktop\Server\World\*.*" /s /e "D:\Users\Jacob Smith\Desktop\Server\World Save\"

    Notice that wildcards have to be within path quotation marks, parameters just after the end quotation mark of source path, followed by a space before the begin quotation mark of target path.

    Oh shit I am complicated after a few whiskies...

    Kari
      My Computer


  5. Posts : 21
    Windows 7 Home Premium 64bit
    Thread Starter
       #5

    I understand most of that.

    I did all that but it still got the same error. I looked the error up online and i found that I either need to 'enable administrative shares, or have the batch file run as the admin (Im the only person ever on this laptop) using the /runas command. I have never signed in as admin, I think I had changed the name to Jacob Smith and customed the password. Maybe you can try and tell me how to do the /runas because i tried ways of doing the other thing, complicated, didn't work.

    You do get complicated after a few whiskeys. I wonder what you'd do after an entire bottle of pure alchahol. Probably solve string theory, make a time machine that runs off of love, and invent a machine to increase the human brains capacity usage to use the force.
      My Computer


  6. Posts : 21
    Windows 7 Home Premium 64bit
    Thread Starter
       #6

    who's complicated now? huh?
      My Computer


  7. Posts : 21
    Windows 7 Home Premium 64bit
    Thread Starter
       #7

    figured it out. I had no clue what the C: and D: things were, but they looked familiar. I looked up the phrase "what is a drive in batch file commands" and found that the hard drive is labled as the C: drive and the CD drive is labled D:. the guy I got this stuff from was posting about copying to a CD. I remembered the drive things from tech class, but I thought Batch file ones were different.

    Thank you so much for trying to help me, and I now know for later stuff. Plus, I now know about the /e argument and, as it turns out, will help because I do have an empty file in the world file. You are awesome.
      My Computer


  8. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #8

    Not knowing about your IT lingo level, let's have a a short "Path 101".

    Letters A to Z followed by colon are used by Windows computers to identify disk drives. This system we still have and use exists thanks for early DOS operating systems. Traditionally drive identifiers A: and B: are (were) reserved for floppy drives, C: for first hard drive where you OS is installed and D: for first removable media drive, normally CD and / or DVD drive.

    Floppy drives are almost extinct so basically also the identifiers A: and B: are today free for hard drives and removable media drives but to keep the logics of the system if you use default settings when installing Windows it skips A: and B: installing OS on C: instead and gives identifier D: for your first CD/DVD drive, naming additional hard drives and other possible (internal and external) drives starting from E:.

    The Backslash "\" is used on DOS / Windows command language to separate folders (earlier Directories) on a path statement. Thus a typical path statement consists a drive identifier followed by a root level (main) folder and possible subfolders, all separated with backslashes. When path statement does not end with so called wildcards or a filename, it points to the last subfolder on path and all content of it. If it ends with a filename or wildcards it points to that/those files that match the criteria.

    Examples.

    • By default a Windows 7 user folder is located on C: hard drive, in root level folder Users' subfolder USERNAME, so for instance my user folder could by default be found in C:\Users\Kari. Notice the backslash signs, first one to separate drive C: from the root level folder Users, the second to separate root level folder from its subfolder Kari.
      .
    • I want to copy everything including subfolders but no empty folders on my user folder to an external hard drive X:, creating a subfolder Kari on X: root level folder Backup Files. The syntax is:
      Code:
      xcopy C:\Users\Kari\*.* /s "X:\Backup Files\Kari\"
      Notice I did not put the source path (C:\Users\Kari) within quotation marks. I could have done it, no prob there, but because that path statement does not have any spaces the quotation marks are not needed. Target however has a space so quotation marks are obligatory.
      .
    • I want to copy all photos from My Pictures taken last year to a USB stick currently having the drive identifier P:, to its root level folder Photos 2011. As I know my digital camera names all photos as YEAR-MONTH-DAY-IDNUMBER.png (for instance 2012-NOV-18-PIC0112.png), I can use XCOPY with source and target paths, using wildcards to pick the files to be copied. Syntax:
      Code:
      xcopy "C:\Users\Kari\My Pictures\2011*.png" "P:\Photos 2011\"


    Path 102 only if requested .

    Kari
      My Computer


  9. Posts : 21
    Windows 7 Home Premium 64bit
    Thread Starter
       #9

    Ok, didn't know I'd get a mini-lecture here, but it's nice to know all that more clearly. You do explain things quite well, as long as you're not drunk, lol. I don't think I need any more info on the path stuff, but thanks for all the help.
      My Computer


  10. Posts : 418
    N/A
       #10

    Please mark this thread as solved.
    Thanks!
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:13.
Find Us