Page 1 of 1

Replace string with parent folder name

Posted: Mon Jan 31, 2022 9:12 pm
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!

Re: Replace string with parent folder name

Posted: Thu Feb 03, 2022 11:14 am
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!