Identify numeric file name and move

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
dazedandconfused2
Newbie
Posts: 13
Joined: Tue Aug 29, 2006 1:50 am

Identify numeric file name and move

Post by dazedandconfused2 » Sat Jul 04, 2009 3:29 pm

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.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Jul 04, 2009 6:57 pm

Another example where RegEx is the ideal tool.

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
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.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Jul 04, 2009 8:18 pm

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.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

dazedandconfused2
Newbie
Posts: 13
Joined: Tue Aug 29, 2006 1:50 am

Post by dazedandconfused2 » Sat Jul 04, 2009 10:36 pm

Thanks VERY much

Sort of the way I was going but was never going to get there.

Works exactly like I want it to.

All filenames are lowercase by default so no need to adjust that.

You are all on my Christmas list for valuable prizes and fancy trips to exotic locations :wink:

Thanks again

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sun Jul 05, 2009 12:25 am

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.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Jul 05, 2009 7:14 am

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.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts