Here's the problem (and I really don't understand why I've never run into this before) - both files and directories created by me (because I really think these characters make the name(s) of the files/directories more "descriptive" which I really need because of my poor memory) and files I regularly download from a particular web site contain many "unsafe" characters - particularly open and close parenthesis and the ampersand. Well, generally speaking, when I am executing code that processes file and directory names I use one of the "@Safe..." functions to get around what could be a significant problem, and everything works fine. However, when I try in some way to deal with one of these "Safe" names with the files and directories as they actually exist in the file system, the "safe" name no longer matches the (actual) "unsafe" names that the file actually have, so that things like "@FileSize[...]" no longer work (although it does work for files whose names contain ampersands without using a "@Safe..." function if the file name is enclosed in double-quotes). Following is a simple example to illustrate exactly what I mean:
First, an existing file:
Now, a very simple batch file named "SafeFileNameMatchTest.btm" that completely illustrates the problem:
And, finally, the (not really surprising) results of executing the above batch file:
As you can easily see, and not at all surprisingly, the "Safe'd" name no longer matches the real file name so that the "@FileSize" function fails. I haven't really deeply thought about this as of yet, but it strikes me that some "@UnSafe" functions would be the best (if not only) way to work around the problem.
Or is there an already a way to accomplish this (actually relatively simple in principle) task?
I will add here that I did already try to "Unsafe /D:" the open and close parenthesis and, for reasons I really didn't understand at the time and have now forgotten (bad memory as usual), that didn't work, and I really didn't "investigate" that very much because that "solution" wouldn't work, as far as I know, for the ampersand anyway.
First, an existing file:
Code:
[Z:\]dir /K /M *paren*
1/18/2012 20:24 0 This File Has a (Parenthetical) Name
Code:
@Echo "%@ExecStr[PDir /(fn) Z:\*paren*]"
@Echo %@FileSize["%@ExecStr[PDir /(fn) Z:\*paren*]"]
@Echo "%@SafeExp[@ExecStr[PDir /(fn) Z:\*paren*]]"
@Echo %@FileSize["%@SafeExp[@ExecStr[PDir /(fn) Z:\*paren*]]"]
Code:
[Z:\]SafeFileNameMatchTest
"This File Has a (Parenthetical) Name"
0
"This File Has a (Parenthetical) Name"
-1
Or is there an already a way to accomplish this (actually relatively simple in principle) task?
I will add here that I did already try to "Unsafe /D:" the open and close parenthesis and, for reasons I really didn't understand at the time and have now forgotten (bad memory as usual), that didn't work, and I really didn't "investigate" that very much because that "solution" wouldn't work, as far as I know, for the ampersand anyway.