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.
Use part of the directory name in the replace string
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.
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.