For example, if %1 is "c:\t*t\s*\*.txt" then "%~f1" could expand to "c:\test\subfolder\file.txt". But if the path is changed to "c:\t*t\z*\*.txt" and no folder exists beginning with z, then the expansion becomes "c:\test\z*\*.txt".
Not only does the ~f modifier understand * and ?, it also understands the poorly documented "<" and ">" wildcards.
All well and good. But then StackOverflow user Mofi pointed out some weird behavior to me at https://stackoverflow.com/questions/614 ... 4_61446617. It turns out that if a node consists of nothing but wildcards and possibly dots, then the ~f modifier does not look at the file system, but rather converts the wildcard node into a single dot


So modifying my earlier example a bit, "c:\t*t\?\*.*" becomes "c:\test\.\." Very weird. I was guessing it might have something to do with how Windows implements the backward compatibility hack of "dir *.*" being the same as "dir *". But then I discovered one last bit of weirdness - the wildcards are expanded normally if the node is the root node of a volume. For example, "c:\*" becomes "c:\$Recycle.Bin" on my machine. But "c:\*\*" becomes "c:\$Recycle.Bin\."
Dave Benham