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.

help with simple batch file issue

  • 28-02-2016 03:18PM
    #1
    Registered Users, Registered Users 2 Posts: 3,219 ✭✭✭


    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, Registered Users 2 Posts: 3,219 ✭✭✭cojomo2


    think I figured it out:

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


  • Registered Users, Registered Users 2 Posts: 4,222 ✭✭✭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, Registered Users 2 Posts: 3,219 ✭✭✭cojomo2


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


  • Registered Users, Registered Users 2 Posts: 36,095 ✭✭✭✭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