Я использую библиотеку Глобализация (от Microsoft):
Это отличный проект для локализации чисел, валют и дат и их автоматического форматирования в соответствии с языком пользователя. ! ... и, несмотря на то, что это должно быть расширение jQuery, в настоящее время это 100% независимая библиотека. Я предлагаю всем вам попробовать! :)
findstr
can do regexes under Windows just fine. I'd try:
dir /b | findstr /i "^[0-9][0-9]*\.pdf$"
The "dir /b"
gives you the filenames only, one per line. The regex matches one or more digits followed by a period followed by your desired extension. For any extension, you could do:
dir /b | findstr "^[0-9][0-9]*\.[^\.]*$"
Obviously, if there are other cases more complicated, you can adjust the regex to suit. It doesn't have the full power of UNIX regexes but it's reasonably good.
The following command file shows how you can process each pdf file in the current directory that meets your "all-numeric" requirement.
@echo off
setlocal enableextensions enabledelayedexpansion
for /f "usebackq" %%i in (`dir /b ^| findstr /i "^[0-9][0-9]*\.PDF$"`) do (
set fspec=%%i
echo.Processing !fspec!
)
endlocal
The site http://www.robvanderwoude.com/batchfiles.php is a very good resource for CMD file magic (and many more things).
Windows предоставила вам улучшенный инструмент программирования, начиная с Win98. Он называется vbscript.
Set objFS = CreateObject("Scripting.FileSystemObject")
strFolder = "c:\test"
Set objFolder = objFS.GetFolder(strFolder)
For Each strFile In objFolder.Files
strFileName = strFile.Name
strExtension = objFS.GetExtensionName(strFile)
strBase = objFS.GetBaseName(strFile)
If IsNumeric(strBase) Then 'check if numeric
WScript.Echo strBase
'continue to process file here.......
End If
Next
для получения дополнительной информации о vbscript прочтите руководство