Welcome Guest.   Make a donation to an author on the site April 19, 2014, 12:14:44 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Read the Practical Guide to DonationCoder.com Forum Search Features
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: DONE: File Search and Replace  (Read 12276 times)
darklight_tr
Charter Member
***
Posts: 39



View Profile Give some DonationCredits to this forum member
« on: January 14, 2008, 02:13:40 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:54 PM by darklight_tr » Logged
justice
Supporting Member
**
Posts: 1,885



Solve issues simply.

View Profile WWW Give some DonationCredits to this forum member
« Reply #1 on: January 14, 2008, 04:34:44 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.
Logged

justice
Supporting Member
**
Posts: 1,885



Solve issues simply.

View Profile WWW Give some DonationCredits to this forum member
« Reply #2 on: January 15, 2008, 04:49:20 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:19 PM by justice » Logged

darklight_tr
Charter Member
***
Posts: 39



View Profile Give some DonationCredits to this forum member
« Reply #3 on: January 15, 2008, 09:58:55 AM »

That works perfectly!  Thanks a ton!  cheesy
Logged
justice
Supporting Member
**
Posts: 1,885



Solve issues simply.

View Profile WWW Give some DonationCredits to this forum member
« Reply #4 on: January 15, 2008, 10:10:42 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.
Logged

Molasar
Participant
*
Posts: 1


View Profile Give some DonationCredits to this forum member
« Reply #5 on: January 29, 2008, 06:04:52 PM »

 Sad 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.

Logged
justice
Supporting Member
**
Posts: 1,885



Solve issues simply.

View Profile WWW Give some DonationCredits to this forum member
« Reply #6 on: January 30, 2008, 03:37:41 AM »

Hmm there is no information in the logs at all? Which version are you using? Interesting note on the replace command lol
Logged

darklight_tr
Charter Member
***
Posts: 39



View Profile Give some DonationCredits to this forum member
« Reply #7 on: January 30, 2008, 08:12:16 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:42 PM by darklight_tr » Logged
darklight_tr
Charter Member
***
Posts: 39



View Profile Give some DonationCredits to this forum member
« Reply #8 on: April 14, 2008, 01:41:21 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.
Logged
NACarter
Supporting Member
**
Posts: 3


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #9 on: April 18, 2008, 05:15:29 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
Logged
darklight_tr
Charter Member
***
Posts: 39



View Profile Give some DonationCredits to this forum member
« Reply #10 on: April 21, 2008, 08:46:22 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. Wink  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:12 AM by darklight_tr » Logged
mouser
First Author
Administrator
*****
Posts: 32,674



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #11 on: April 21, 2008, 10:58:17 AM »

nice teamwork  thumbs up thumbs up
Logged
NACarter
Supporting Member
**
Posts: 3


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #12 on: April 22, 2008, 05:33:30 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
Logged
darklight_tr
Charter Member
***
Posts: 39



View Profile Give some DonationCredits to this forum member
« Reply #13 on: April 22, 2008, 09:51:32 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:44 AM by darklight_tr » Logged
rjbull
Charter Member
***
Posts: 2,701

View Profile Give some DonationCredits to this forum member
« Reply #14 on: April 22, 2008, 10:51:14 AM »

Did nobody think of using XXCopy "the boldly extended xcopy?"

[copy or print]
/U  Updates the files that already exist in destination.

/S  Copies directories and subdirectories except empty ones.

/Y  Overwrites existing files without prompt




Logged
darklight_tr
Charter Member
***
Posts: 39



View Profile Give some DonationCredits to this forum member
« Reply #15 on: April 23, 2008, 09:54:24 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.
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.039s | Server load: 0.05 ]