Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Batch file to copy user docs from laptop to network share

  • 16-08-2007 02:48PM
    #1
    Registered Users, Registered Users 2 Posts: 10,290 ✭✭✭✭


    Hi,

    I've been asked to make a batch file to copy users docs and outlook psts to a network share.
    These are laptop users that come into the office about once a month.

    Below is one I've come up with this mornnig.
    It will search their user profile, the root of c: and a scan of d:

    Some of the users will not have a d partition.
    How can I get the script to check if there's a d drive on the laptop or to skip if there's just c:?

    ATM you get a prompt to "Ignore, retry, fail" when running the below on a 1 partition machine which I'd like to avoid.
    echo off
    cls
    echo *******************************************************************************
    echo * This script will copy the following file
    echo * types to to S:\File_Backup from your PC
    echo *
    echo *  - *.DOC - Word
    echo *  - *.XLS - Excel
    echo *  - *.PAB - Personal Address Book
    echo *  - *.PDF - Adobe PDF
    echo *  - *.PST - Outlook Archive
    echo *  - *.PPT - Power Point
    echo * 
    echo * Only source files that are newer than the destination files will be copied
    echo *******************************************************************************
    pause
    echo *
    echo >> c:\%username%_File_Backup_to_HomeDIR.txt
    date /t >> c:\%username%_File_Backup_to_HomeDIR.txt
    time /t >> c:\%username%_File_Backup_to_HomeDIR.txt
    
    echo Computer name : %computername% > c:\%username%_File_Backup_to_HomeDIR.txt
    echo *
    echo Copying Word docs
    echo *
    XCOPY c:\*.doc %HOMESHARE%\File_Backup\ /C /D /Y /I
    XCOPY d:\*.doc %HOMESHARE%\File_Backup\ /C /S /D /Y /I
    XCOPY %userprofile%\*.doc %HOMESHARE%\File_Backup\ /C /S /D /Y /I
    echo *
    echo Copying Excel files
    echo *
    XCOPY c:\*.xls %HOMESHARE%\File_Backup\ /C /D /Y /I
    XCOPY d:\*.xls %HOMESHARE%\File_Backup\ /C /S /D /Y /I /q
    XCOPY "%userprofile%"\*.xls %HOMESHARE%\File_Backup\ /C /S /D /Y /I
    echo *
    echo *******************************************
    echo * Please close Outlook before you proceed *
    echo *******************************************
    pause
    echo Copying Personal Address Book
    echo *
    XCOPY c:\*.pab %HOMESHARE%\File_Backup\ /C /D /Y /I
    XCOPY d:\*.pab %HOMESHARE%\File_Backup\ /C /S /D /Y /I
    XCOPY "%userprofile%"\*.pab %HOMESHARE%\File_Backup\ /C /S /D /Y /I
    echo *
    echo Copying Outlook Archive
    echo *
    XCOPY c:\*.PST %HOMESHARE%\File_Backup\ /C /D /Y /I
    XCOPY d:\*.PST %HOMESHARE%\File_Backup\ /C /S /D /Y /I
    XCOPY "%userprofile%"\*.PST %HOMESHARE%\File_Backup\ /C /S /D /Y /I
    echo *
    echo Copying Adobe PDF files
    echo *
    XCOPY c:\*.pdf %HOMESHARE%\File_Backup\ /C /D /Y /I
    XCOPY d:\*.pdf %HOMESHARE%\File_Backup\ /C /S /D /Y /I
    XCOPY "%userprofile%"\*.pdf %HOMESHARE%\File_Backup\ /C /S /D /Y /I
    echo *
    echo Copying Power Point files
    echo *
    XCOPY c:\*.PPT %HOMESHARE%\File_Backup\ /C /D /Y /I
    XCOPY d:\*.PPT %HOMESHARE%\File_Backup\ /C /S /D /Y /I
    XCOPY "%userprofile%"\*.PPT %HOMESHARE%\File_Backup\ /C /S /D /Y /I
    pause
    

    Cheers for reading


Comments

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


    [php]if not exist D:\*.* goto :bottom
    xcopy d:
    :bottom[/php]


    also have a look at robo copy - it has more tweaks than xcopy , main one would be file size, and better behaved on a network


  • Registered Users, Registered Users 2 Posts: 10,290 ✭✭✭✭Standard Toaster


    I went for this in the end:
    dir D:
    
    if %errorlevel% EQU 1 goto Ddrive
    
    goto Cdrive
    
    :Ddrive
    
    
    XCOPY d:\*.doc %HOMESHARE%\File_Backup\
    

    Which works fine but I think your method is better.
    Cheers for that. I'll give robo copy a look tonight.


Advertisement