Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

problem with copying files in batch file....

  • 14-12-2012 2:55pm
    #1
    Registered Users, Registered Users 2 Posts: 1,362 ✭✭✭


    I want to create a batch file that will allow me to copy from a local hard drive (f:\data) to a local usb hard drive (d:data) that i have attached to my PC

    here is the syntax of the batch file....

    "
    cmd

    f:

    cd data

    xcopy *.* /s /d /Y d:\data"


    Howver when i run this batchfile it just opens the command prompt...
    it wont browse to the f drive which is the second line of the batch file etc..
    what am i doing wrong?


Comments

  • Registered Users, Registered Users 2 Posts: 976 ✭✭✭unseenfootage


    All you need is this line :

    xcopy /s c:\source d:\target


  • Registered Users, Registered Users 2 Posts: 1,731 ✭✭✭GreenWolfe


    If you want to suppress the prompt, add "@echo off" (without the quotes) to the top of the batch file.


  • Moderators, Arts Moderators, Regional Abroad Moderators Posts: 11,107 Mod ✭✭✭✭Fysh


    You don't need the "cmd" at the start and I think your syntax is wrong. Unseenfootage's post gives you the basic command you need, but the Microsoft documentation page for the xcopy command (see here) has the following as an example of an xcopy command that uses if switches to handle error codes:
    @echo off 
    rem COPYIT.BAT transfers all files in all subdirectories of
    rem the source drive or directory (%1) to the destination rem drive or directory (%2) 
    
    xcopy %1 %2 /s /e 
    
    if errorlevel 4 goto lowmemory 
    if errorlevel 2 goto abort 
    if errorlevel 0 goto exit 
    
    :lowmemory 
    echo Insufficient memory to copy files or 
    echo invalid drive or command-line syntax. 
    goto exit 
    
    :abort 
    echo You pressed CTRL+C to end the copy operation. 
    goto exit 
    
    :exit
    


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 93,591 Mod ✭✭✭✭Capt'n Midnight


    TBH have a look at robocopy instead

    xcopy just isn't up to copying large numbers of files , fine for a small folder


  • Moderators, Arts Moderators, Regional Abroad Moderators Posts: 11,107 Mod ✭✭✭✭Fysh


    Or you could script up synctoy and invoke the script via task scheduler - see here.


  • Advertisement
  • Closed Accounts Posts: 414 ✭✭Bosh


    This is the syntax I use to run a a backup every time the PC shuts down: (one line of it obviously :p)

    XCOPY "C:\Users\Office\Desktop\*.*" "K:\Backup\Admin\Desktop" /d/s/e/y

    Yours would be along the lines of:

    XCOPY "F:\Data\*.*" "D:\Data" /d/s/e/y

    The switches are as explained in the link in Fysh's post.

    HTH


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 93,591 Mod ✭✭✭✭Capt'n Midnight


    mozy backup free version also makes backups to local drives too


Advertisement