Replace string with parent folder name

Tool for Search and Replace across multiple files.
Post Reply
cubilas
Posts: 3
Joined: Mon Jan 31, 2022 9:07 pm

Replace string with parent folder name

Post by cubilas »

Hello!

TextCrawler has been the answer to so many of my problems, I'm proud to be a registered user.

Here's my question..

I'm trying to locate "<SampleName>SAMPLE" in multiple files and replace the word SAMPLE with the folder name that the file resides in.

Lets say the file is "C:\Anything\More\Trumpet\MyFile.xml"

I want to replace the text "<SampleName>SAMPLE" inside that file with "<SampleName>Trumpet"

Any ideas on how to accomplish this? I will be modifying a lot of different files in different folders. Thanks!
User avatar
DigitalVolcano
Site Admin
Posts: 1731
Joined: Thu Jun 09, 2011 10:04 am

Re: Replace string with parent folder name

Post by DigitalVolcano »

Unfortunately the only replace options are
-Path+FileName
-FileName

and not the top path (which is what you want).

I can't think of a way of doing it without including the file name as well!
Post Reply