topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 7:46 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: DONE: File Search and Replace  (Read 24881 times)

darklight_tr

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 39
    • View Profile
    • Donate to Member
DONE: File Search and Replace
« on: January 14, 2008, 02:13 PM »
This has been solved!  See the bottom of this post for the download!  :Thmbsup:

I am trying to find a program that allows me search for and replace files with a source file.

Example:

I have a large directory structure that has numerous folders and subfolders.  There are many scripts that execute from this structure, and some rely on psexec.exe.  Since many people access this structure, a copy of psexec.exe is stored in each of the script directories instead of one central location.  The problem comes in when I want to update psexec.exe to the newest version.  Finding and replacing each old one with a new one is a tedious task.

So, I would like a program that can search for every instance of a specific file name and replace it with a source file that I specify.

Any help would be greatly appreciated.

UPDATE: (01/01/09)

File Propagator has been removed, as it has been replaced by File Replicator.
« Last Edit: January 01, 2009, 04:39 PM by darklight_tr »

justice

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,898
    • View Profile
    • Donate to Member
Re: IDEA: File Search and Replace
« Reply #1 on: January 14, 2008, 04:34 PM »
It will be relatively easy to write an AHK script for this in an hour or so I reckon,
the AHK can execute a 'dir /b /s psexec.exe > result.txt' from a base folder, then read that result.txt in line by line and copy the psexec.exe from the AHK working dir to these destination paths. I won't have time tomorrow but later on during the week I could have a go if noone else has.

justice

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,898
    • View Profile
    • Donate to Member
Re: FilePropagator 1.0
« Reply #2 on: January 15, 2008, 04:49 AM »
Try this:

FilePropagator 1.0
Replace all instances of a certain file in a folder with an updated copy. Select a root folder and the updated file that you want to replace all instances of, and confirm the operation. Search.txt and replace.txt logfiles are kept in the application folder. Autohotkey source provided.

edit: download removed by request of topicstarter as it has a serious bug in it that is now fixed.


« Last Edit: April 14, 2008, 01:59 PM by justice »

darklight_tr

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 39
    • View Profile
    • Donate to Member
Re: IDEA: File Search and Replace
« Reply #3 on: January 15, 2008, 09:58 AM »
That works perfectly!  Thanks a ton!  :D

justice

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,898
    • View Profile
    • Donate to Member
Re: DONE: File Search and Replace
« Reply #4 on: January 15, 2008, 10:10 AM »
No problemo, just check the replace.txt logfile the first few times to make sure there are no bugs -- I tested it on newly created folderstructures and you're the second person to use it hehe.

Molasar

  • Participant
  • Joined in 2008
  • *
  • Posts: 1
    • View Profile
    • Donate to Member
Re: DONE: File Search and Replace
« Reply #5 on: January 29, 2008, 06:04 PM »
 :( Doesn't work for me, it let me select the folder and the file, but then do nothing.

I'm using WinXP with SP2.

Anyways i've found a command that i didn't know before, the REPLACE command did a very good and fast job. I think if you use that you wouldn't need to read that result.txt in line by line.

http://img82.imageshack.us/img82/9159/replacejd2.gif
DONE: File Search and Replace

justice

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,898
    • View Profile
    • Donate to Member
Re: DONE: File Search and Replace
« Reply #6 on: January 30, 2008, 03:37 AM »
Hmm there is no information in the logs at all? Which version are you using? Interesting note on the replace command lol

darklight_tr

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 39
    • View Profile
    • Donate to Member
Re: DONE: File Search and Replace
« Reply #7 on: January 30, 2008, 08:12 AM »
Hmm...I just tested v2.1.0 again (on Windows XP SP2) and it worked fine.  As justice said, what version are you using?  Do the logs report anything?

I'll do some research into the Replace command.  Maybe I can use that instead of the existing command.

EDIT: I created a Beta version that uses the Replace command, but it will need more testing.  Check it out in the bottom of the first post.

EDIT 2: The version using the Replace command has been released.  Check it out in the bottom of the first post.
« Last Edit: February 04, 2008, 03:04 PM by darklight_tr »

darklight_tr

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 39
    • View Profile
    • Donate to Member
Re: DONE: File Search and Replace
« Reply #8 on: April 14, 2008, 01:41 PM »
I wanted everyone to know that I discovered and fixed a rather annoying bug in File Propagator.  This was most likely the bug that Molasar experienced.  See the first post for details.

NACarter

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 3
    • View Profile
    • Donate to Member
Re: DONE: File Search and Replace
« Reply #9 on: April 18, 2008, 05:15 AM »
I am having trouble with v3.1.0.  The source file isn't propagated - when I look at the replace.txt file it's contents say "No file replaced".  Trying the replace command from a command window worked ok.  I do have spaces in the folder names, but this version is supposed to be ok with that.  I am using Win XP SP2.

Nick

darklight_tr

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 39
    • View Profile
    • Donate to Member
Re: DONE: File Search and Replace
« Reply #10 on: April 21, 2008, 08:46 AM »
I am having trouble with v3.1.0.  The source file isn't propagated - when I look at the replace.txt file it's contents say "No file replaced".  Trying the replace command from a command window worked ok.  I do have spaces in the folder names, but this version is supposed to be ok with that.  I am using Win XP SP2.

Nick

D'oh!  I missed one of the variables, so the spaces in your directory name choked the script.  I fixed it this time, I promise. ;)  Please see File Propagator v3.1.1 in the first post which fixes the problem.  Thanks for noticing that and reporting it!
« Last Edit: April 21, 2008, 08:55 AM by darklight_tr »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: DONE: File Search and Replace
« Reply #11 on: April 21, 2008, 10:58 AM »
nice teamwork  :up: :up:

NACarter

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 3
    • View Profile
    • Donate to Member
Re: DONE: File Search and Replace
« Reply #12 on: April 22, 2008, 05:33 AM »
Thanks darklight_tr.  I can now confirm that it works as expected.  :Thmbsup:

There's one thing that confused me at first. The choice of the phrase "source folder" is a bit misleading - it's really the root destination folder, and nothing to do with the source of the file being copied.  Perhaps this could be modified in your new GUI version.

Nick

darklight_tr

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 39
    • View Profile
    • Donate to Member
Re: DONE: File Search and Replace
« Reply #13 on: April 22, 2008, 09:51 AM »
Thanks for the feedback.

The changes I made are built on top of justice's original v1.0 source, and the terminology used by the script is unchanged.  I'll take a look at it when I build the GUI version.

The GUI version will be be built from scratch, and will no longer rely on justice's source code.  I do have to thank him for the fact that it was his script that got me interested in AutoHotkey, and for allowing me to modify his File Propagator source.
« Last Edit: April 22, 2008, 09:55 AM by darklight_tr »

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,199
    • View Profile
    • Donate to Member
Re: DONE: File Search and Replace
« Reply #14 on: April 22, 2008, 10:51 AM »
Did nobody think of using XXCopy "the boldly extended xcopy?"

/U  Updates the files that already exist in destination.

/S  Copies directories and subdirectories except empty ones.

/Y  Overwrites existing files without prompt





darklight_tr

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 39
    • View Profile
    • Donate to Member
Re: DONE: File Search and Replace
« Reply #15 on: April 23, 2008, 09:54 AM »
Did nobody think of using XXCopy "the boldly extended xcopy?"

Interesting suggestion, but I was trying to avoid using commercial software to accomplish this.  XXCopy's freeware license forbids commercial use, so I wouldn't be able to use it at work anyways.

The Windows Replace command does the job just fine.