Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Copy particular file and replace it into multiple sub-directories  (Read 2712 times)

0 Members and 1 Guest are viewing this topic.

ng2010

    Topic Starter


    Greenhorn

    Hi,

    I am new in creating complex batch file.

    I am having two folders, one is "Master" and another is "Projects". In Master, i have master file named with core.css.

    I would like to create a batch file which will search for core.css in Projects folder and its subfolders (apprx. 140) and where find replace it with Master>core.css file.

    Anyone can please provide me exact command for this.

    Regards,
    Nitin

    marvinengland



      Hopeful

      Thanked: 11
      Re: Copy particular file and replace it into multiple sub-directories
      « Reply #1 on: July 05, 2010, 05:30:57 PM »
      I am having two folders, one is "Master" and another is "Projects". In Master, i have master file named with core.css.

      I would like to create a batch file which will search for core.css in Projects folder and its subfolders (apprx. 140) and where find replace it with Master>core.css file.



      C:\test>type project0705.bat
      @echo off
      dir /s /b  core.css

      dir /s /b  core.css |  findstr "project" > core.txt

      echo type  core.txt

      type  core.txt

      for  /f "delims="  %%i in (core.txt) do (
      copy c:\test\master\core.css   %%i
      )

      Output:

      C:\test>project0705.bat
      C:\test\master\core.css
      C:\test\project\project1\core.css
      C:\test\project\project3\core.css
      type  core.txt
      C:\test\project\project1\core.css
      C:\test\project\project3\core.css
              1 file(s) copied.
              1 file(s) copied.

      C:\test>
      USA

      ng2010

        Topic Starter


        Greenhorn

        Re: Copy particular file and replace it into multiple sub-directories
        « Reply #2 on: July 05, 2010, 11:22:50 PM »
        Thank you so much marvin, it really works for me.

        Do you have any idea how to apply this approach in VSS like my Projects and Master folder is in VSS so i need to first check out all core.css in folders and subfolders then applied copy command.

        e.g. I am using ss checkout $/Projects/project1/core.css

        I know it is out of this topic ;) , but would be great if got any help on this.