Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Problem with XCOPY  (Read 33000 times)

0 Members and 1 Guest are viewing this topic.

NCwill

    Topic Starter


    Rookie

    Problem with XCOPY
    « on: May 20, 2008, 04:54:22 PM »
    I am trying to create a batch procedure that will copy a group of files from a flash drive into a temp directory on my hard drive, and then have the ability to copy those files onto multiple other flash drives (one at a time).  So I created the following:

    Code: [Select]
    Echo What is the flash card drive letter? (no colon needed)
    REM Sets the user entered drive letter as the drive letter of the flash drive.
    set /p DriveLetter=

    Echo Insert the flash card with the current election files into the drive.
    pause

    REM Delete (or remove) the "temp" directory to make sure old files are not copied
    RMDIR /s /q C:\Flash_Copy\temp

    REM make a new "temp" directory
    mkdir C:\Flash_Copy\temp

    REM copy everything from the flash drive to the temp directory.
    xcopy %DriveLetter%: C:\Flash_Copy\temp /E


    :LOOP

    REM After the source has been copied to the "temp" directory it prompts to insert a new card into the flash drive.
    REM When this is done it formats the card in flash card drive
    FORMAT %DriveLetter%: /V:TEST /Q


    CLS

    REM It should begin to copy from the "temp" directory to the freshly formatted flash card in the flash card drive.
    xCOPY "C:\Flash_Copy\temp" %DriveLetter%: /E /S
    pause

    GOTO LOOP

    Well the procedure works ok until the last xcopy.  It gives an error of:

    Code: [Select]
    File creation error - The parameter is incorrect.

    Unable to create directory - G:\
    0 File(s) copied
    Press any key to continue . . .

    I suspect it has something to do with the fact that when the files are copied from the source flash drive onto the hard drive it asks you to "insert disk into drive G" (which I do with another flash card) but does not fully terminate the xcopy procedure because the batch program continues to the next step which is to format the flash drive, which it does without problem but the next step is to use xcopy to copy the files from the hard drive to the flash card causes problems.

    At first I thought it was a bad drive or corrupted files, but if I manually (using windows) copy the files off the flash drive and place them into the temp directory and then use xcopy to put them onto another flash drive (using a batch procedure) it works fine.  So it has something to do with using xcopy to put the files onto my hard drive.

    Any suggestions? 

    Thanks!

    DarkendHeart



      Beginner

      Thanked: 1
      Re: Problem with XCOPY
      « Reply #1 on: May 20, 2008, 05:39:57 PM »
      Well I'm not 100% sure but try adding this to the first xcopy command "/v /y /l" to it so it would now look like this...
      Code: [Select]
      xcopy %DriveLetter%: C:\Flash_Copy\temp /E /V /Y /L
      « Last Edit: May 20, 2008, 06:49:39 PM by DarkendHeart »

      NCwill

        Topic Starter


        Rookie

        Re: Problem with XCOPY
        « Reply #2 on: May 21, 2008, 08:20:53 AM »
        Thanks for suggestion but unfortunately that did not work.

        Actually putting /L on the first copy gave me hope because it did not error out, but then I realized it did not actually copy anything to the hard drive from the first flash card.  Once I removed the /L I got the same error as above.

        Any other suggestions?  Or other ways to do the same thing?  I am 99% sure it has something to do with using the first xcopy to get the files into the temp directory on my hard drive but I cannot figure out how to get around it.  Is there another way to copy all files and folders from one drive to another without using xcopy?

        Thanks again.

        llmeyer1000



          Intermediate

          Thanked: 1
          Re: Problem with XCOPY
          « Reply #3 on: May 21, 2008, 09:25:51 AM »
          What is your Operating system?

          First, you don't want both /E & /S
          /S           Copies directories and subdirectories except empty ones.
          /E           Copies directories and subdirectories, including empty ones.
          /E will do it all!

          The following code works for me in Windows XP. (My Flash drive is L:)
          Code: [Select]
          xcopy "C:\Flash_Copy\temp" L: /E

          In the past In other versions of DOS/Windows, I have had trouble with Xcopy being very very picky. I think you may need to specify the root directory. L: or L:\ does not always do it for good ol' dos. You may need to use the "full path" and specify the root directory. The period(or dot) directory is always the current directory.

          Try the following
          Code: [Select]
          xcopy "C:\Flash_Copy\temp\." %DriveLetter%:\. /E

          It is not always necessary to give dos a full path, but it never hurts.
          For clarity, I would also add the \. to the path in the earlier line that works already, as follows:
          Code: [Select]
          xcopy %DriveLetter%:\. C:\Flash_Copy\temp\. /E

          Dos will sometimes assume what you want as it did on this line. Other times the full path is required, as I believe it may be on the problem line.

          NCwill

            Topic Starter


            Rookie

            Re: Problem with XCOPY
            « Reply #4 on: May 21, 2008, 09:32:20 AM »
            I am trying this out in XP. 

            I will give what you suggested a try and report back.

            NCwill

              Topic Starter


              Rookie

              Re: Problem with XCOPY
              « Reply #5 on: May 21, 2008, 09:50:41 AM »
              Ok I made the modifications you suggested to the .bat file.  Here is my current code:

              Code: [Select]
              Echo What is the flash card drive letter? (no colon needed)
              REM Sets the user entered drive letter as the drive letter of the flash drive.
              set /p DriveLetter=

              Echo What is the flash card drive letter? (no colon needed)
              REM Sets the user entered drive letter as the drive letter of the flash drive.
              set /p DriveLetter=

              Echo Insert the flash card with the current election files into the drive.
              pause

              REM Delete (or remove) the "temp" directory to make sure old files are not copied
              RMDIR /s /q C:\Flash_Copy\temp\

              REM make a new "temp" directory
              mkdir C:\Flash_Copy\temp\

              REM copy everything from the flash drive to the temp directory.
              xcopy %DriveLetter%:\. C:\Flash_Copy\temp\. /E
              Pause

              REM :LOOP

              REM After the source has been copied to the "temp" directory it prompts to insert a new card into the flash drive.
              REM When this is done it formats the card in flash card drive
              FORMAT %DriveLetter%: /V:ESS_FLASH /Q

              REM CLS

              REM It should begin to copy from the "temp" directory to the freshly formatted flash card in the flash card drive.

              xcopy "C:\Flash_Copy\temp\." %DriveLetter%:\. /E
              pause
              REM GOTO LOOP



              As I am sure you will notice I commented out the loop, cls, and goto just to make sure they were not causing any issues.  Well unfortunately it did not work and I ended on the same error.  I have included all the various things displayed on the screen.  I am at a loss as to what to do.

              Code: [Select]


              G:\.\Wav\e80.wav
              G:\.\Wav\e81.wav
              G:\.\Wav\e82.wav
              G:\.\Wav\e83.wav
              G:\.\Wav\e84.wav

              [...]

              G:\.\BXT\BAL00006.bxt
              G:\.\BXT\BAL00007.bxt
              G:\.\BXT\BAL00008.bxt
              G:\.\BXT\BAL00009.bxt
              G:\.\BXT\BitMap.BXT
              G:\.\WXT\wav.wxt
              557 File(s) copied
              Press any key to continue . . .
              Insert new disk for drive G:
              and press ENTER when ready...
              The type of the file system is FAT.
              QuickFormatting 244M
              Initializing the File Allocation Table (FAT)...
              Format complete.

                256,352,256 bytes total disk space.
                256,352,256 bytes available on disk.

                      4,096 bytes in each allocation unit.
                     62,586 allocation units available on disk.

                         16 bits in each FAT entry.

              Volume Serial Number is B458-5B52
              File creation error - The parameter is incorrect.

              Unable to create directory - G:\
              0 File(s) copied
              Press any key to continue . . .

              llmeyer1000



                Intermediate

                Thanked: 1
                Re: Problem with XCOPY
                « Reply #6 on: May 21, 2008, 10:19:16 AM »
                Maybe try adding this to file before problem line.
                Code: [Select]
                %DriveLetter%:
                pause
                CD\
                pause

                NCwill

                  Topic Starter


                  Rookie

                  Re: Problem with XCOPY
                  « Reply #7 on: May 21, 2008, 06:24:32 PM »
                  Nope, same error.

                  Is there another way to copy files and folders from one drive to another without using xcopy?

                  llmeyer1000



                    Intermediate

                    Thanked: 1
                    Re: Problem with XCOPY
                    « Reply #8 on: May 21, 2008, 07:11:37 PM »
                    I don't know of a better method than xcopy. Plus, I don't think that xcopy is the problem. It works fine for me, but on a drive not just formatted. The suspisions you mentioned in your first post may be close to right, but I don't think exactly right.

                    I was trying to force the OP to re-initialize on the drive after the format with the last idea. You could try another command followed by a pause, and look for another error that might zero in on the problem a bit better. Try:
                    Code: [Select]
                    dir %DriveLetter%:
                    pause
                    or
                    Code: [Select]
                    copy onefile.ext %DriveLetter%:
                    pause

                    I hope to find time later to try the whole procedure, including the disk format like you are doing.

                    Dias de verano

                    • Guest
                    Re: Problem with XCOPY
                    « Reply #9 on: May 22, 2008, 12:23:28 AM »
                    Quote
                    xcopy %DriveLetter%:\. C:\Flash_Copy\temp\. /E

                    What is the reason for the single dot at the end of each path?

                    llmeyer1000



                      Intermediate

                      Thanked: 1
                      Re: Problem with XCOPY
                      « Reply #10 on: May 22, 2008, 11:07:22 AM »
                      Quote
                      xcopy %DriveLetter%:\. C:\Flash_Copy\temp\. /E
                      What is the reason for the single dot at the end of each path?

                      He tried it because I suggested it earlier.

                      In the past In other versions of DOS/Windows, I have had trouble with Xcopy being very very picky. I think you may need to specify the root directory. L: or L:\ does not always do it for good ol' dos. You may need to use the "full path" and specify the root directory. The period(or dot) directory is always the current directory.

                      Try the following
                      Code: [Select]
                      xcopy "C:\Flash_Copy\temp\." %DriveLetter%:\. /E

                      It is not always necessary to give dos a full path, but it never hurts.
                      For clarity, I would also add the \. to the path in the earlier line that works already, as follows:

                      Code: [Select]
                      xcopy %DriveLetter%:\. C:\Flash_Copy\temp\. /E
                      Dos will sometimes assume what you want as it did on this line. Other times the full path is required, as I believe it may be on the problem line.

                      In some cases DOS requires the name of the directory and .(DOT) is a valid directory name. It is the name of the current directory, the same as ..(DOT DOT) is the name of the parent directory. In some cases .(DOT) will work where *.* doesn't and in others not. Further testing has shown that this was not the case here. What he really needed was to add *.* to the source directory as shown.
                      Code: [Select]
                      xcopy /E "C:\Flash_Copy\temp\*.*" %DriveLetter%:\.
                      The above line works as is. It may also work without the \. on the destination directory. I didn't test it both ways, as this command works perfectly.

                      I cleaned up the entire batch as follows:
                      Code: [Select]
                      @echo off

                      :: Set the user entered drive letter as the drive letter of the flash drive.
                      echo.&echo.&echo.
                      echo     1. Enter the the flash card drive letter? (no colon needed)
                      echo.&echo.
                      echo     2. Press "Enter"
                      echo.&echo.
                      set /p DriveLetter=
                      cls

                      echo.&echo.&echo.
                      echo     1. Insert the "Flash Drive" with the current election files into the drive.
                      echo     ( This is the source disk. )
                      echo.&echo.
                      echo     2. Press any Key to Continue.
                      echo.&echo.
                      pause >nul
                      cls

                      :: Delete (or remove) the "temp" directory to make sure old files are not copied
                      If exist C:\Flash_Copy\temp\ RMDIR /s /q C:\Flash_Copy\temp\

                      :: copy everything from the flash drive to the temp directory.
                      xcopy %DriveLetter%:\. C:\Flash_Copy\temp\ /E

                      echo.&echo.&echo.
                      echo     Source Files Copied to Hard Drive!
                      echo.&echo.

                      :: User prompted to insert a new card into the flash drive.
                      echo     1. Remove the source "Flash Drive"
                      echo     2. Insert the destination "Flash Drive"
                      echo     3. Wait until the destination "Flash Drive" has initialized.
                      echo.&echo.
                      echo     4. Press any Key to Continue.
                      echo.&echo.
                      pause >nul
                      cls

                      :LOOP

                      :: Format the card in flash card drive.
                      FORMAT %DriveLetter%: /V:ESS_FLASH /Q
                      cls

                      :: Xcopy from the "temp" directory to the freshly formatted flash card in the flash card drive.
                      xcopy /E "C:\Flash_Copy\temp\*.*" %DriveLetter%:\.
                      echo.&echo.&echo.
                      echo     Source Files Copied to Flash Drive!

                      :: User prompted to insert a new card into the flash drive.
                      echo.&echo.
                      echo     1. Remove the finished "Flash Drive"
                      echo     2. Insert the next destination "Flash Drive"
                      echo     3. Wait until the destination "Flash Drive" has initialized.
                      echo.&echo.
                      echo     4. Press any Key to Continue.
                      echo.&echo.
                      pause >nul
                      cls

                      GOTO LOOP


                      Dias de verano

                      • Guest
                      Re: Problem with XCOPY
                      « Reply #11 on: May 22, 2008, 11:14:27 AM »
                      I asked because I use xcopy to backup my data folders every day and I don't use a dot.

                      e.g.

                      Code: [Select]
                      C:\>xcopy "C:\Program Files\Lyceum" "S:\Backup\Lyceum"




                      llmeyer1000



                        Intermediate

                        Thanked: 1
                        Re: Problem with XCOPY
                        « Reply #12 on: May 23, 2008, 02:50:22 AM »
                        I asked because I use xcopy to backup my data folders every day and I don't use a dot.
                        e.g.
                        Code: [Select]
                        C:\>xcopy "C:\Program Files\Lyceum" "S:\Backup\Lyceum"

                        I don't doubt it!  ;) Notice that in my first post, I told NCwill that code similar to yours also works for me:
                        First, you don't want both /E & /S
                        /E will do it all!
                        The following code works for me in Windows XP. (My Flash drive is L:)
                        Code: [Select]
                        xcopy "C:\Flash_Copy\temp" L: /E

                        I commented that:
                        Quote
                        In the past in other versions of DOS/Windows, I have had trouble with Xcopy being very very picky.
                        &
                        It is not always necessary to give dos a full path, but it never hurts.
                        &
                        Dos will sometimes assume what you want as it did on this line. Other times the full path is required, as I believe it may be on the problem line.

                        I stand behind those statements!

                        For example, if you are not specific enough, as in the following:
                        Code: [Select]
                        C:\>xcopy /E "C:\Machine Tool Company" "L:\Machine Tool Company"
                        xcopy gets confused and asks you:
                        Code: [Select]
                        Does L:\Machine Tool Company specify a file name
                        or directory name on the target
                        (F = file, D = directory)?

                        Is xcopy really so stupid that it does not know that what you want is to duplicate the "Machine Tool Company" folder from the C: drive to the L: drive? No. The problem is that I was not specific enough.
                        The problem can be corrected several ways but the answer lies in being more specific.
                        Both of the following(and probably other ways) will create the destination folder (and copy the files) that you wanted:
                        Code: [Select]
                        xcopy /E "C:\Machine Tool Company\*.*" "L:\Machine Tool Company\*.*"
                        Code: [Select]
                        xcopy /E "C:\Machine Tool Company" "L:\Machine Tool Company\*.*"
                        In NCwill's case, there was another problem involved. Due to the fact that the target disk had been "freshly" formatted, Windows /DOS had temporarily lost contact with the disk. That can be seen by this test. Open a copy of Explorer to the flash drive. Run the batch file. At the completion of the format, that copy of explorer is closed. I'm not sure of the technical reason for this behavior, but I ASSume that dos is programed to reinitialize the disk at that time. Whatever the exact reason, the fact that the disk has been "freshly" formatted, throws a curve at the following xcopy command. I tested numerous variations and found that many possible command lines worked if a format was NOT involved. The next example uses code nearly identical to the code Dias suggested. It does not work when a format is involved, but works fine without the format.

                        The following three lines   WILL ALL   work on a disk that was   NOT   "freshly" formatted.
                        But ...                           WILL NOT   work on a disk that        WAS   "freshly" formatted.
                        Code: [Select]
                        xcopy /E "C:\Flash_Copy\temp" %DriveLetter%:
                        xcopy /E "C:\Flash_Copy\temp" %DriveLetter%:\.
                        xcopy /E "C:\Flash_Copy\temp" %DriveLetter%:\*.*

                        The following three lines   WILL ALL   work on a disk that       WAS   "freshly" formatted.
                        Code: [Select]
                        xcopy /E "C:\Flash_Copy\temp\*.*" %DriveLetter%:
                        xcopy /E "C:\Flash_Copy\temp\*.*" %DriveLetter%:\.
                        xcopy /E "C:\Flash_Copy\temp\*.*" %DriveLetter%:\*.*

                        The following line is the BEST CHOICE. It is the MOST COMPLETE in the eye's of "DOS"
                        Code: [Select]
                        xcopy /E "C:\Flash_Copy\temp\*.*" %DriveLetter%:\*.*

                        Part of the problem here lies in the format command being used here,
                        But a big part of the problem lies in the fact that we are lazy.
                        Code: [Select]
                        copy *.* A:works fine because dos is programmed to ASSume that you mean copy all files in the current directory since you did not specify the source directory. It also assumes that you meant the root of A: as your destination.
                        BUT ... If you tried to use copy to create a folder on a named temp:
                        Code: [Select]
                        copy *.* A:\tempCopy is not able to create folders, so dos ASSumes that you wanted to copy all the files in the current directory to a new file on the root of A:
                        Even though there were several files to copy, dos returns with:
                        Code: [Select]
                                1 file(s) copied.Why "1 file"? ??? DOS wrote one new file named temp and copied the contents of all the files into the one. It ASSumed that was what you wanted.


                        Which brings us back around to my point that:
                        It,s best not to ASSume that DOS will be able to figure out exactly what you want to do.
                        It is always better to give dos the full path, even though many times it may work without it.
                        We all know what ASSuming does, but since we all tend to be a little lazy we tend to give dos just enough of the path to get by.

                        Sometimes, as in this case, being lazy might just bite us all in the ... you know where! ;)


                        PS: A few weeks(or months) back there was another formatting/backup problem that we resolved for the fellow with the RD command and the use of the \.(DOT) to represent the root directory for the RD command that required a directory name be specified(*.* did not work). I guessed (wrongly in this case) that xcopy was looking for a directory name in NCwill's xcopy command.
                        I would hazard a guess that the problem a few weeks back could have been the same as NCwill's. If so, this solution would have been better all the way around.
                        « Last Edit: May 23, 2008, 03:05:09 AM by llmeyer1000 »

                        NCwill

                          Topic Starter


                          Rookie

                          Re: Problem with XCOPY
                          « Reply #13 on: May 29, 2008, 07:56:54 PM »
                          Sorry everyone for going MIA.  Work has been crazy and I have not gotten a chance to get on here.  I promise I will look over everything tomorrow once I get back into the office and give a status report.

                          I truly appreciate all the help!

                          NCwill

                            Topic Starter


                            Rookie

                            Re: Problem with XCOPY
                            « Reply #14 on: May 30, 2008, 09:40:17 AM »
                            Ok, drum roll please....

                            Woohoo! You solved the problem!

                            Thank you so much llmeyer1000...  I now need to read and re-read your explanation as to what the problem was in hopes I can avoid this type of thing in the future.  Thanks again.