• How to fix xcopy

    Author
    Topic
    #504361

    I wrote a backup script for batch. Works except for the XCOPY
    command. I have compared against other such script and do not see the cause for the problem.
    The following is verified:
    dest=E:/buTOP/Desktop (Note:buTOP pre-exists on flash drive)
    source=C:/Users//Desktop

    The command used for testin is:
    xcopy %inID%:%source% %dest% /E /F /I /J /K /R /S /V /Y 1>NUL

    It produces this error: File not found – Desktop
    Any help?

    Viewing 7 reply threads
    Author
    Replies
    • #1550540

      I wrote a backup script for batch. Works except for the XCOPY
      command. I have compared against other such script and do not see the cause for the problem.
      The following is verified:
      dest=E:/buTOP/Desktop (Note:buTOP pre-exists on flash drive)
      source=C:/Users//Desktop

      The command used for testin is:
      xcopy %inID%:%source% %dest% /E /F /I /J /K /R /S /V /Y 1>NUL

      It produces this error: File not found – Desktop
      Any help?

      The one thing I always had a problem with in batch files was remembering that all path statements to file and Folders on the HDD had to use the backslash , not the forward slash / as used in switches and the Internet.

      Before you wonder "Am I doing things right," ask "Am I doing the right things?"
      • #1550548

        LOL!

        Recursive LOL! It’s emojis, emojis all the way down!!

    • #1550544

      So I have a couple of comments, at least.

      To the error in question. XCopy requires a file specification on the source and you haven’t provided one. You’ve only provided a folder. My recommended fix would be:

      source=C:UsersDesktop*.*

      Note that I’ve incorporated Berton’s comment as well (folder delimiters should be backslashes). Some environments allow you to substitute one for another but it can be a minefield doing that, IMO.

      I’m also baffled by your use of the %inID% variable. By appending a colon on this you are indicating a drive. However the variable %source% already contains a drive. Windows should error out if you specify [noparse]”Drive:Drive:”[/noparse]. The only conceivable valid use of this form I can think of would be a UNC name. However your syntax doesn’t conform to UNC rules either.

    • #1550552

      B,

      When using strings with colons in them it is best to enclose them in noparse tags :

      43517-noparsetags

      I fixed your post above.

      HTH :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      • #1550668

        Thanks 4 the input!!
        In fact the forward slashes were a consequence of having to type rather than cut/paste from the command screen and are/were backslashes. Sorry 4 mis info.
        The %inID% variable was a hang over which is now removed.
        source=C:UsersDesktop
        with a proper username for .
        and
        dest=E:buTOPDesktop
        when rerun with the correction :

        Code:
        xcopy %source%  %dest%  /E /F /I /J /K /R /S /V /Y  1>NUL
        

        it produces:
        Invalid drive specification.
        Any help now??

    • #1550671

      A couple of thoughts:
      Does the subFolder of Desktop already exist in E:buTOP?
      Does having a backslash after Desktop make any difference? [dest=E:buTOPDesktop]

      Before you wonder "Am I doing things right," ask "Am I doing the right things?"
    • #1550672

      Does the username have a space in it? Thus:

      C:Usersfred bloggsDesktop

      If so it may need double quotes around it (I think)

      Eliminate spare time: start programming PowerShell

    • #1550676

      Also, I’m not sure if this matters, but I would put spaces at the end:

      Put 1 > NUL rather than 1>NUL

      Group "L" (Linux Mint)
      with Windows 10 running in a remote session on my file server
    • #1550825

      What is the 1>nul ?? supposed to do ??

      What does :echo %source% %dest%
      pause
      return if put in the head of the batch file?
      :cheers:

      🍻

      Just because you don't know where you are going doesn't mean any road will get you there.
      • #1550845

        What does :echo %source% %dest%
        pause
        return if put in the head of the batch file?

        David,

        Sorry I missed that on the first post.

        The command Echo to the screen the expanded command: Xcopy %source% %dest% and then pause execution until you press a key.

        e.g. if source is set to C:Test.Dat and dest is set to X:TransferFile*.*

        You should see:
        Copy C:Test.Dat X:TransferFile*.*
        Press any key to continue . . .
        on your screen.

        HTH :cheers:

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

        • #1551296

          David,

          Sorry I missed that on the first post.

          The command Echo to the screen the expanded command: Xcopy %source% %dest% and then pause execution until you press a key.

          e.g. if source is set to C:Test.Dat and dest is set to X:TransferFile*.*

          You should see:
          Copy C:Test.Dat X:TransferFile*.*
          Press any key to continue . . .
          on your screen.

          HTH :cheers:

          That was a question to the OP to check what is actually stored in those variables. Thanks any way 😀
          :cheers:

          🍻

          Just because you don't know where you are going doesn't mean any road will get you there.
    • #1550827

      David,

      1 is one of the standard output streams. It is standout or the standard output stream which is to the screen.
      > nul redirects it to the Null device effectively silencing the bat file with the exception of errors.

      HTH :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      • #1550843

        Try running the following, to see what will happen:

        xcopy %source% %dest%

        In other words, simplify the command, for troubleshooting purposes.

        Before doing that, open a command prompt and type SET to make sure that your environment variables are correctly set.

        Group "L" (Linux Mint)
        with Windows 10 running in a remote session on my file server
      • #1551295

        David,
        It is standout or the standard output stream which is to the screen.
        HTH :cheers:

        Thanks RG
        Ah, I wonder if I knew that and forgot. :p
        :cheers:

        🍻

        Just because you don't know where you are going doesn't mean any road will get you there.
    Viewing 7 reply threads
    Reply To: How to fix xcopy

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: