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

help with simple batch file issue

Options
  • 28-02-2016 3:18pm
    #1
    Registered Users Posts: 3,216 ✭✭✭


    Hi,

    I'm trying to create a simple batch file for end users that will serach their entire c:\ and make a copy of all files with a specefic extension. These files will be copied to a folder created on their U:

    I was going to use Xcopy, but that is copying the folder structure too, which is unwanted.

    This is what I have:

    @echo off
    c:
    mkdir backup
    for /R "c:\" %%f in ("*.rsf") do copy "%%f" u:\backup\ >nul

    This works - copies over all .rsf file from the C to the U, however it also copies over all .rsft files - which I don't want.

    What should I adjust so only .rsf files are copied?
    Thanks


Comments

  • Registered Users Posts: 3,216 ✭✭✭cojomo2


    think I figured it out:

    for: /r "c:\" %%f in (*.rsf) do if /i !%%~xf"==".rsf" copy "%%a" u:\backup\ >nul


  • Registered Users Posts: 3,833 ✭✭✭Hijpo


    cojomo2 wrote: »
    think I figured it out:

    for: /r "c:\" %%f in (*.rsf) do if /i !%%~xf"==".rsf" copy "%%a" u:\backup\ >nul

    What about robocopy??


  • Registered Users Posts: 3,216 ✭✭✭cojomo2


    Hijpo wrote: »
    What about robocopy??
    doesn't robocopy copy directory structures also?


  • Registered Users Posts: 36,167 ✭✭✭✭ED E


    cojomo2 wrote: »
    doesn't robocopy copy directory structures also?

    Robocopy has plenty of arguments, I'm pretty sure you can flatten output.


Advertisement