regex - Windows advanced file matching -
I am trying to use a batch file in the list of files in the directory, such as file name only (zero extension ) Matches only numerical patterns, such as 125646543 something like PDF, which is a regex [\ d] + \. It would be easy to express as a PDF, but of course I have no such details with the Windows-only mechanism ... I'm trying to do it with Windows-only the target since the system Can not install anything else on the server, and it must be supported at least on Windows Server 2000 and 2003.
I have some more advanced than this typical example or something more common than just old * and?
I have already tried to add numbers in the file name to set / A, but since it defines the strings as the environment variable 0 is if they are defined It does not work well, I also tried to use %% ~ no GTR 0, but this report corresponds to file like report.pdf, because it is comparing the string in this case is.
findstr
can regexes just under Windows. I will try:
dir / b Findstr / i "^ [0-9] [0-9] * \ .pdf $"
"dir / b"
gives you only the filename , one per line. The Rexex matches one or more digits, which is according to the period after your desired expansion. For any detail, you can:
bid / b | Finder "^ [0-9] [0-9] * \. [^ \.] * $"
Obviously, if there are more complex cases in other cases, then you adjust the regex You can scratch. It does not have full power of UNIX regexes but it is quite good.
The following instructions file shows how you can process each PDF file in your current directory that meets your "all-numerical" requirement. / P>
@echo closed sitelocole enabled extensions have been enabled / for F "usebackq" %% i (% dir / b ^ | findstr / i "^ [0-9] [0-9] * \ PDF $ "`) (FSPC = %% Set Echo. Processing! FSPEC!) Endlocal
Site CMD file is a great resource for magic (and many things) < / P>
Comments
Post a Comment