I need to be able to identify a numeric filename out of a directory list and move it.
The filename syntax is
1234567890_(variable length alpha numeric)_(single alpha character).doc
eg. 3633183958_d203856a4d_o.doc
The first part of the name is always 10 numeric characters.
The moving part is no problem but I could use some help to identify the name.
Identify numeric file name and move
Moderators: JRL, Dorian (MJT support)
-
- Newbie
- Posts: 13
- Joined: Tue Aug 29, 2006 1:50 am
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Another example where RegEx is the ideal tool.
Note that the current of RegEx seems to be Case Insensitive. Need Version Version 11.1.05 (Mar 02 2009) or higher to use Macro Scheduler RegEx. Can use VBS RegEx in earlier versions.
Code: Select all
// GetFileList>c:\windows\*.doc,vFileList,;
// Preceeding line is actual line to be used. Commented out for testing.
// Next line is a test line to simulate a directory listing. Includes names that do not match the pattern
Let>vFileList=1234567890_abc_A.doc;0987654321_123_B.doc;12345678_abc_C.doc;1234_!123_D.doc;1234567890abc.doc;123456abc789.doc;1357924680_abc123_E.doc
Let>vNeedle=[0-9]{10}_.*?_[a-z]\.doc
Let>vHaystack=%vFileList%
RegEx>%vNeedle%,%vHaystack%,0,vFiles,vFileCount,0,,
// Display the results
Let>vCount=0
Label>Loop
Let>vCount=%vCount%+1
Let>vFileName=vFiles_%vCount%
MessageModal>%vFileCount% files were found.%CRLF%%CRLF%File number %vCount% is named %vFileName%
If>%vCount%=%vFileCount%,End,Loop
Label>End
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
By default expressions are case insensitive. Use (?-i) to turn OFF case insensitive matching (i.e. make case sensitive). E.g. Try these:
RegEx>A,That HAT,0,matches,n,0
RegEx>(?-i)A,That HAT,0,matches,n,0
The first will match both "A" chars, the second will match only the second.
RegEx>A,That HAT,0,matches,n,0
RegEx>(?-i)A,That HAT,0,matches,n,0
The first will match both "A" chars, the second will match only the second.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Newbie
- Posts: 13
- Joined: Tue Aug 29, 2006 1:50 am
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Thanks for that syntax for enabling Case Sensitivity. Could find no reference that used the "i" like that. Can you point me to the correct perl manual?
Would be good to add something like this to the HELP for RegEx:
Default is for Case Sensitivity to be OFF.
Add (?-i) to the front of the needle to enable Case Sensitivity.
Would be good to add something like this to the HELP for RegEx:
Default is for Case Sensitivity to be OFF.
Add (?-i) to the front of the needle to enable Case Sensitivity.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I used RegExBuddy to tell me that I needed (?-i) - it inserted it for me. But I just went to the RegEx topic in the help file, clicked on the PCRE Library link and then clicked on the documentation links which both show i as the modifier for case insensitivity.
Adding PCRE/Perl documentation to the Macro Scheduler help file is unfeasible and out of scope. It already links to the PCRE library pages.
Adding PCRE/Perl documentation to the Macro Scheduler help file is unfeasible and out of scope. It already links to the PCRE library pages.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?