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

Author Topic: can v replac multiple files(sameName) under a dir?  (Read 2050 times)

0 Members and 1 Guest are viewing this topic.

fathima

  • Guest
can v replac multiple files(sameName) under a dir?
« on: February 22, 2007, 01:26:11 AM »
Hi All,

Is it possible to replace some files with same names under a directory by some ms dos command..

I will explain the scenario in details

There is directory which has many sub diretcories. And all these subdirectories contain a file with common name.Likeways there are around 1000 files with the common name
But we dont know the directory structure in which this file is contained.
Now my requirement is to replace this common files with a new file.
Is it possible to do this?

Directory structure will look somewhat like this

                  Dir1

|
   Dir1              Dir2   Dir3  Dir4 ....
     |                  |
Sub1 sub2       sub3 sub4
Commonfie          |
                     sub1
                       |
                     commonfile

Now i need to replace the common files coming under parent directory with a new file..

Is it possible to do this?

If my question is not clear,please get back to me

Regards
Fathima
  

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: can v replac multiple files(sameName) under a
« Reply #1 on: February 22, 2007, 03:42:43 AM »
You could try running a directory list of this common file with the /s and /b switches. Redirect the list to a file. This will produce a list of where the common file lives and where you will copy the new common file

Open up the file in an editor and using some basic search/replace you should be able to create a batch file where each line is a copy command of the the new common file to the destination produced by the dir list.

Sample dir list:
Code: [Select]
c:\dir1\sub1\commonfile.txt
c:\dir2\sub3\sub2\commonfile.txt

Batch file after search/replace in editor:
Code: [Select]
copy c:\newcommonfile.txt c:\dir1\sub1\commonfile.txt
copy c:\newcommonfile.txt c:\dir2\sub3\sub2\commonfile.txt

By saving the edited code as a batch file, it can do the work for you.

Note: the code snippets are examples only; your data will be different.

 8-)
« Last Edit: February 22, 2007, 04:17:41 AM by Sidewinder »
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein