Hi

Can anybody help me with the script of first finding and then overwriting a file.I need only the batch script.

thanks
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Using DOS tools to do this job would be tortuous, to say the least. Off the top of my head, you'd need to pipe the output from 'DIR /S' to a file, then use 'FIND' to extract the path, somehow passing that text to COPY. [shudder]

You would be much better off using VBScript or PowerShell. There are many, many examples on recursively walking a folder tree, which you could then adapt for your purposes.
Answered 05/15/2009 by: VBScab
Red Belt

Please log in to comment
0
I agree with VBScab. It will be much easier (and more manageable) to do with a scripting language.

I like VBScript, but for something like this, I would use a simple biterscript. I will write a quick script for you. I will assume the file you are looking for is X.ext, it is burried somewhere in folder "C:/folder" or its subfolders, and you want to replace it with C:/Y.ext.


# Script replace.txt
var str list ; lf -rn "X.ext" "C:/folder" > $list
var str file ; lex "1" $list > $file
system copy "C:/Y.ext" $file


To try, download biterscripting ( http://www.biterscripting.com ) , save the above script as C:\scripts\replace.txt, start biterscripting, enter the following command.


script replace.txt


Use double quotes if any of these file/path names contains spaces or other special characters. I have not tested the script.

Patrick
Answered 07/23/2009 by: PatrickMc
Yellow Belt

Please log in to comment
Answer this question or Comment on this question for clarity