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

Author Topic: .bat file that finds and replaces files  (Read 3702 times)

0 Members and 1 Guest are viewing this topic.

cliff

  • Guest
.bat file that finds and replaces files
« on: January 17, 2006, 02:55:09 PM »
To all:
 
First-timer, here.  Hope you can help me look good for my boss.

We want to create a batch file that searchs all the profiles on a workstation (in c:\documents and settings).  And, if it ever finds a file named VersionA.exe, we want to replace it with a file named VersionB.exe.
 
Any hints/tips?  All help would be greatly appreciated.  Thx in advance, - Cliff

p.s.  I did "search" this forum.  Is there, by chance, a library of some .bat files I can explore.  I love dissecting examples.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: .bat file that finds and replaces files
« Reply #1 on: January 17, 2006, 06:15:55 PM »
Code: [Select]
for /d %%a in ("c:\documents and settings\*") do (
      if exist %%a\versionA.exe copy path\versionB.exe %%a\versionA.exe
      )      

You'll need to replace path with something meaningful. I'm not sure you can get into other user's accounts, but that's a whole other animal.

Good luck. 8-)
« Last Edit: January 18, 2006, 05:23:49 AM by Sidewinder »
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein