xcopy help

Discussion in 'Software' started by evilflame2, Jun 4, 2007.

  1. evilflame2

    evilflame2 Private E-2

    hi, i need a batch file that followes certain peramiters

    it needs to

    copy an entire flash drive to a folder in another flash drive
    the drive letter of the first flash drive is unknown but it is the only flash drive in the system (before inserting the second one)
    this is also true for the second flash drive.

    and if possible only as an added bonus, it would autorun on the second flash drive's insert

    i was thinking about using

    xcopy (unknown 1st drive letter):\*.* (unknown 2nd drive letter):\copy /a /e /h /c /k /Q /y

    but the problem would be the drive letters.

    if anyone has a solution or a better way to do this please let me know

    thank you
     
  2. Mada_Milty

    Mada_Milty MajorGeek

    If the batch file is on a flash drive, the drive letter doesn't matter, as you can use relative file paths.

    As for the OTHER drive, I think a parameter might the easiest way to do this.

    Code:
    xcopy *.* %1\copy\*.* /a /e /h /c /k /Q /y
    Would be your code (if the script was on the FIRST drive), and you would have to call the script using the drive letter followed by a colon as a parameter.

    ex

    Code:
    flashcopy.bat f:
    You could make this more automatic (ie NOT have to supply the drive letter) by adding a VBScript layer, but there would have to be some way to uniquely identify each flash drive. Having a hidden file on each, or setting it to use a unique volume name might be ways to accomplish that. Let us know if you're interested!
     
  3. evilflame2

    evilflame2 Private E-2

    i dont really follow you, sorry but let me explain the situation

    my professor wants to be able to stick his flash drive into our computer and have it auto copy my flash drive onto it to grade some of our work. he has to do this for like 25 people once a week

    sorry im kinda new at this batch thing
    maybe that is more clear if i wasn't being clear before

    and the code you gave me xcopy *.* %1\copy\*.*

    what does the 1% modifier modify
     
  4. Mada_Milty

    Mada_Milty MajorGeek

    %1 is a placeholder for the parameter we've given the script.

    So for this script:

    Code:
    xcopy *.* %1\copy\*.*
    (which for the purposes of this thread, I'm calling flashcopy.bat) if you called it like this:

    Code:
    flashcopy.bat f:
    then %1 is equal to f:, so that the computer would ACTUALLY execute:

    Code:
    xcopy *.* f:\copy\*.*
    Now, because we are going to put this script on one of the flash drives, we don't need to know the drive letter for that one, because the script will automatically assume you mean the same directory that it resides in. For the example above, if we DIDN'T include the f: in the call to the script, it would assume that we wanted the files on the same drive, simply copied to the 'copy' subdirectory.

    I've gotten this a bit backwards for your case, since the teacher would have the destination drive, and that would be where we put the batch file. So this might better suit you:

    Code:
    xcopy %1\*.* copy\*.*
    This way, we would only need to tell the script what drive letter the SOURCE files are located at. So, for example, if your flash drive was assigned the letter E:, we would execute this command:

    Code:
    flashcopy.bat e:
    So, this would copy all files on the E: drive to the drive the batch file is sitting on (your teacher's drive), in the 'copy' subdirectory.

    IMO, this is fairly useless however, as your teacher would have to know the source drive letter, and pass it to the script upon execution. This is only one small step away from issuing the whole xcopy command by hand!

    We could POSSIBLY make this more automatic, but we would have to give the script a way to distinguish between the flash drive, and any other drives in the computer. That is why I suggested giving each source drive a hidden file, or changing its volume name. Then the script could look for that file or name, and know that that is where the source files are located.

    On the surface, this doesn't seem practical, as you would need to have all students make the same change to their flash drives. Maybe that's doable... let us know.
     
  5. evilflame2

    evilflame2 Private E-2

    ok, well thanks for your help anyway
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds