Use part of the directory name in the replace string

General discussions about Advanced Find and Replace
Post Reply
vicegod
Posts: 4
Joined: Mon Mar 13, 2006 10:59 pm

Use part of the directory name in the replace string

Post by vicegod » Mon Mar 13, 2006 11:38 pm

Hi, and thanks in advance for any help you can give.

I have lots of files found in subdirectories. I'd like to search the top level, and replace a string in files found in the sub directories with a portion of that sub directories name:

Search Path: \\server\directory ; Search in Subfolders ON
Search For: hrval'101'

This search will return hundreds of results, with the path being in this format:
\\server\directory\rep###\filename.txt with ### being a three digit number.

In filename.txt I'd like to replace hrval'101' with hrval'###', using the last 3 digits in the directory name.

Please let me know if this is possible, or if I should just bite the bullet and fat finger in the directory for the search path and replace script.

Abacre
Site Admin
Posts: 1198
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Post by Abacre » Tue Mar 14, 2006 5:29 pm

Yes, it's possible with AFR.
See http://www.abacre.com/afr/manual/optsbatch.htm page and
"Include File Name into Search Scope" option.

Go to main menu - Action - Options - Batch Replace
check "Modifier S"
check "Modifier M"
uncheck "Modifier G"

Go to Batch replace tab, check on "Use regular expressions".
Put into the grid, search for:
\\\\server\\directory\\rep(\d\d\d)\\.*\r\n(.*hrval)'101'

Replace with:
\r\n$2'$1'

That's all I verified it works perfectly.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

vicegod
Posts: 4
Joined: Mon Mar 13, 2006 10:59 pm

Post by vicegod » Wed Mar 15, 2006 2:48 pm

Sorry to be a pain, but it's coming back with 0 results for that search. It shows that it's reading all the correct directories, but there are no hits. I've double and triple checked the string I'm looking for, and it's there. Any ideas?

Abacre
Site Admin
Posts: 1198
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Post by Abacre » Wed Mar 15, 2006 4:54 pm

Are you sure that the files contain hrval'101' ?
Try plain text search for hrval'101' in files using, for example, Find
operation with Phrase search type.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

vicegod
Posts: 4
Joined: Mon Mar 13, 2006 10:59 pm

Post by vicegod » Wed Mar 15, 2006 5:19 pm

the actual search value is hrval='101' I put the = in myself, but no results. If I just do a plain find, it comes back with several thousand results.
Thanks

vicegod
Posts: 4
Joined: Mon Mar 13, 2006 10:59 pm

Post by vicegod » Wed Mar 15, 2006 5:43 pm

I'll tell you what, it ain't no fun being stoopid. It's working now. I downloaded the newest version. It's going slow, but it's going.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests