1.

Solve : can v replac multiple files(sameName) under a dir??

Answer»

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
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-)



Discussion

No Comment Found