Hi RNIB,
I tried out Bob's code and it worked for me.
Make sure you do not have any spaces before or after the commas in the commands. The leading or trailing spaces become part of the varialble names. Also be sure to Edit>Remove trailing spaces before saving your script.
You can also check the watchlist to see what veriables get created. The easiest way is to do a Debug>Trace.
Gale
Count files in folder based on criteria and select in order?
Moderators: JRL, Dorian (MJT support)
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
For RNIB:
Did you modify the first line to use the directory where your *.wav files are located?
For JRL:
You MUST get familiar with RegEx. FYI, the expression I used in my example also provides a list of all the files that begin with a number. They each are in a sequentially numbered variable %vFiles_n%. If in Debug mode, you will see the variables and their values in the WatchList. Or, you can loop this array to display/write/rename, etc.
You can change the needles to locate files in the haystack that do not begin with numbers and use essentially the same RegEx to locate those files.
Here is an untested example........
--------------------------------------------
For ALL:
And here is an online RegEx testing tool, roll over the expressions to see what they do, see results as you type, many nice features....
http://www.gskinner.com/RegExr/
Did you modify the first line to use the directory where your *.wav files are located?
For JRL:
You MUST get familiar with RegEx. FYI, the expression I used in my example also provides a list of all the files that begin with a number. They each are in a sequentially numbered variable %vFiles_n%. If in Debug mode, you will see the variables and their values in the WatchList. Or, you can loop this array to display/write/rename, etc.
You can change the needles to locate files in the haystack that do not begin with numbers and use essentially the same RegEx to locate those files.
Here is an untested example........
Code: Select all
GetFileList>c:\windows\*.wav,vFileList,;
Let>vNeedle1=[0-9]+[a-z]+.*?\.wav
Let>vNeedle2=;[a-z]+.*?\.wav
Let>vHaystack=%vFileList%
RegEx>%vNeedle1%,%vHaystack%,0,vNumberFiles,vNFileCount,0,,
RegEx>%vNeedle2%,%vHaystack%,0,vAlphaFiles,vAFileCount,0,,
MessageModal> There are %vNFileCount% filenames that start with a number
MessageModal> There are %vAFileCount% filenames that start with a letter
// Insert loops here to process each of the file names........
For ALL:
And here is an online RegEx testing tool, roll over the expressions to see what they do, see results as you type, many nice features....
http://www.gskinner.com/RegExr/
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Sorry Bob, I've been off sick for a few days and only just got back.Bob Hansen wrote:For RNIB:
Did you modify the first line to use the directory where your *.wav files are located?
I've tried it again, and yes I've changed the path to the one containing my WAV files:
Code: Select all
GetFileList>F:\Beyond Ugly\*.wav,vFileList,;
Let>vNeedle=[0-9]+[a-z]+.*?\.wav
Let>vHaystack=%vFileList%
RegEx>%vNeedle%,%vHaystack%,0,vFiles,vFileCount,0,,
MessageModal>There are %vFileCount% filenames that start with a number
I wonder if this might be down to the fact that I'm only running MacroScheduler 10? Unfortunately as a charity and in the current financial climate we can't really afford to upgrade to version 11 at the moment

Hi RNIB,
You were able to purchase the 2 year Upgrade Protection Plan with the original software.
If so, you still have 6 months of free upgrades.
If not, you may be to work something out based on this quote in the "Buy Now" page:
I tried running your code again today. This time the GetFileList is not returning a value. Use the Watch List to make sure all your input variables have values before going into RegEx.
I'm going to see what is wrong with GetFileList now.
Gale
You were able to purchase the 2 year Upgrade Protection Plan with the original software.
If so, you still have 6 months of free upgrades.
If not, you may be to work something out based on this quote in the "Buy Now" page:
It is also possible to run RegEx via VBScript. Or you can use the alternate solution provided by JRL.Want to barter, trade, beg or borrow?
I tried running your code again today. This time the GetFileList is not returning a value. Use the Watch List to make sure all your input variables have values before going into RegEx.
I'm going to see what is wrong with GetFileList now.
Gale
Sorry meant to say earlier that I had tried JRL's script but unfortunately this doesnt seem to work correctly. No matter what folder I point it at it just gives me a count of the total number of WAV files in there.
E.g. if a folder contains 200 WAV files and 190 of them are prefixed with a number I just get a message saying:
Numbered=0
NotNumbered=200
I've learnt a lot over the past week or so in trying to do this and can actually understand 90% of JRL's code but can't figure out where it's going wrong.
E.g. if a folder contains 200 WAV files and 190 of them are prefixed with a number I just get a message saying:
Numbered=0
NotNumbered=200
I've learnt a lot over the past week or so in trying to do this and can actually understand 90% of JRL's code but can't figure out where it's going wrong.
file includes directory
Hi RNIB,
The problem is %file% also includes the directory name.
Add this code after you have captured %dir%
Length>%dir%\X,startdigit.
(The X is just a placeholder for first character of filename)
Then change your Midstr command to:
MidStr>%file%,%startdigit%,1,digit
Gale
The problem is %file% also includes the directory name.
Add this code after you have captured %dir%
Length>%dir%\X,startdigit.
(The X is just a placeholder for first character of filename)
Then change your Midstr command to:
MidStr>%file%,%startdigit%,1,digit
Gale
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact: