Renaming folders and subfolders with a pattern
Posted on 2006-12-01
I could use some help with the thinking on this one.
Suppose I wanted to rename all the folders and subfolders from some root according to a pattern.
For example, suppose I wanted to replace "*fred*" in each of the paths below with ALFREDO.
(To make life a little simpler, only replace the first occurrence in any segment so
\xfred2\yfreddofred\fred.htm would become
Now, I cannot use repeated findfirst/findnext loops because the replacement pattern could contain the patten to match.
It would be nice to do it in one pass, with some sort of recursive follow down the tree algorithm. But again, I don't see how because the Tsearchrec contents (after a rename) would be wrong.
There should be a simple way .. just can't see it for the moment. Maybe something to do with PIDL's?
Assume for the purposes of exposition that the folders to be renamed are
and these would become
If the solution requires PIDL's I could use some code, because I really don't understand them.