Soldato
- Joined
- 25 Mar 2004
- Posts
- 15,983
- Location
- Fareham
Greetings guys
I am looking to find a way to check if a text string contains only numbers, I am writing a script that will go through all subfolders in a specified folder and check the name of the folder in order to delete older ones.
At the moment the folder contains one folder labelled for each day in the format YYYYMMDD, for example:
20090923
20090922
20090921
The script below will return a text string value for each folder name (the last 8 characters only) and the date the folder was created.
This is my problem: I need to make sure the FolderName only contains numbers so that I don't delete the wrong folders. The folders in the folder are 95% log files that can be deleted, but there are a couple of others such as "webserver" and "installer" that I don't want the script to touch.
I was thinking of using Regular Expressions to check this but don't know how to use them properly, can anyone advise how to achieve this or give me an example using Regular Expressions?
Thanks!
I am looking to find a way to check if a text string contains only numbers, I am writing a script that will go through all subfolders in a specified folder and check the name of the folder in order to delete older ones.
At the moment the folder contains one folder labelled for each day in the format YYYYMMDD, for example:
20090923
20090922
20090921
The script below will return a text string value for each folder name (the last 8 characters only) and the date the folder was created.
Code:
LogFilePath = "D:\Program Files\Research In Motion\BlackBerry Enterprise Server\Logs\"
Set objFSO = createobject("Scripting.filesystemobject")
Set ObjFolder = objFSO.getfolder(LogFilePath)
Set ObjFolders = objFolder.SubFolders
For each Folder in ObjFolders
FolderName = Right(Folder, 8)
FolderDateCreated = Folder.DateCreated
wscript.echo FolderName
wscript.echo ""
wscript.echo FolderDateCreated
Next
This is my problem: I need to make sure the FolderName only contains numbers so that I don't delete the wrong folders. The folders in the folder are 95% log files that can be deleted, but there are a couple of others such as "webserver" and "installer" that I don't want the script to touch.
I was thinking of using Regular Expressions to check this but don't know how to use them properly, can anyone advise how to achieve this or give me an example using Regular Expressions?
Thanks!