DOS Batch file help needed

Discussion in 'Windows Legacy Support (XP and earlier)' started by RacybabeUK, Mar 4, 2005.

  1. RacybabeUK

    RacybabeUK

    Joined:
    Dec 2, 2002
    Messages:
    59
    Location:
    Lincs England UK
    I have attempted to write a batch file and am testing it at home before putting it on to my bosses laptop at work. The aim of the batch file is to automate the copying of files held in My documents ( on my bosses laptop held on c: to a folder on Z: which is a designated mapped network drive on our server (2003). I haven't been able to work out how to put a "switch" at the end of the line to prevent the message "do you wish to overwrite this file?" when the same file is copied to the new folder.

    The wording on my batch file is:

    copy C:\My Documents\test folder\*.*/ C:\My Documents\test

    and I named the file: test.bat (using notepad of course). I put the Batch file on my desktop and clicked it to run but it went through a quick movement but nothing has copied over.

    Please advise what i have missed out. I know it must be something really simple but I haven't looked at batch files for years.

    Many thanks

    Suzanne
     
  2. galaxian

    galaxian

    Joined:
    Jun 12, 2000
    Messages:
    499
    2 suggestions:

    If you really want a batch file use XCopy instead.

    If you are open to other options, check out Karen's Replicator
     
  3. HAL9000

    HAL9000

    Joined:
    Dec 18, 1999
    Messages:
    17,633
    Location:
    Regina, Saskatchewan, Canada
    Use XCOPY as suggested. At a command prompt, type in XCOPY /? and you will get the list of commands of which there are switches to either overwrite, or leave existing files so you don't get the prompt as the batch runs.
     
  4. glc

    glc Forum Administrator Staff Member

    Joined:
    May 26, 2000
    Messages:
    47,722
    Location:
    Joplin MO
    That's not wise testing within the same directory structure - create a folder off C called test folder. Here's the syntax:

    C:\>xcopy "c:\my documents\test folder"\*.* "c:\test folder" /r/i/c/h/k/e/y

    This will overwrite everything and will continue on errors.

    The quotes are REQUIRED if you are using directory names with spaces, and the placement needs to be exact. Also, on his laptop, is My Documents directly on C, or is it really in c:\documents and settings\username\my documents? If this is Win9x/ME, replace xcopy with xcopy32 or you will lose long file names in the copy process.
     
  5. RacybabeUK

    RacybabeUK

    Joined:
    Dec 2, 2002
    Messages:
    59
    Location:
    Lincs England UK
    Thanks for all the advice - It is late but so far as I can see you don't download xcopy - it is just a "hidden" feature that is available within windows? BTW my boss is a woman but she is not IT literate so anything i do impresses her LOL

    I tried the following in a batch file but nothing happened again apart from a blank notepad folder called xcopy appeared on my desktop!!

    C:\>xcopy c:\my documents\test folder\*.* C:\testfolder/r/i/c/h/k/e/y

    We are using XP Professional and the documents are more than likely in c:\documents and settings etc but I can't check until Monday morning.

    We don't have to use a batch file - anything is possible so long as it does the job required. Would Karen's replicator be easier to use?
     
  6. glc

    glc Forum Administrator Staff Member

    Joined:
    May 26, 2000
    Messages:
    47,722
    Location:
    Joplin MO
    Your syntax is still not right. My Documents has a space in it, so you must use the quotes. There is a space required between testfolder and /r... .

    If this is XP, My Documents is NOT a root folder.

    This is what you need, substitute your logged in username for username:

    xcopy "c:\documents and settings\username\my documents"\*.* c:\testfolder /r/i/c/h/k/e/y
     
  7. RacybabeUK

    RacybabeUK

    Joined:
    Dec 2, 2002
    Messages:
    59
    Location:
    Lincs England UK
    Success

    :)

    Many thanks - did a test run at home and made sure i had the quotes and space as correct and it worked. Just a case of making sure the path is the correct one now when i do the batch file for my boss :)

    Cheers

    Suzanne
     
  8. GRP

    GRP

    Joined:
    Feb 6, 2005
    Messages:
    41
    xcopy command

    Am I missing something here. I've used xcopy many times to copy entire directorys and never had to use the *.* just the directory name such as "xcopy c:\tc\nuprog c:\tc\bin\oldprog". Why is the *.* being used in this instance?
     
  9. glc

    glc Forum Administrator Staff Member

    Joined:
    May 26, 2000
    Messages:
    47,722
    Location:
    Joplin MO
    As with anything else, there's several ways to do something. It's the syntax I've used for over 10 years now and it never fails to work for me.
     

Share This Page