Page 1 of 1

Use part of the directory name in the replace string

Posted: Mon Mar 13, 2006 11:38 pm
by vicegod
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.

Posted: Tue Mar 14, 2006 5:29 pm
by Abacre
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.

Posted: Wed Mar 15, 2006 2:48 pm
by vicegod
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?

Posted: Wed Mar 15, 2006 4:54 pm
by Abacre
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.

Posted: Wed Mar 15, 2006 5:19 pm
by vicegod
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

Posted: Wed Mar 15, 2006 5:43 pm
by vicegod
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.