Once again I have searched and found some close but not close enough for my limited understanding.
I have a section in my script that enters the result of a variable into a file save dialog.
However, as you know, Windows hates certain characters in file names. So I am trying to strip them from the variable.
To be more specific; I need to read variable %filname% and replace anything that isn't "A-Z, a-z, 1-0, with probably an underscore or even a space. (I don't need to worry about the file extension)
So: my$file.name would become my_file_name
Can anyone point me in the right direction? I can do it by replace but there are so many characters to replace... I hoped that there may be an "allow only" feature.
Thanks.
Allowing only certain characters?
Moderators: Dorian (MJT support), JRL
- Phil Pendlebury
- Automation Wizard
- Posts: 543
- Joined: Tue Jan 16, 2007 9:00 am
- Contact:
Allowing only certain characters?
Phil Pendlebury - Linktree
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Quick point in one direction, untested. I think it is the right direction. .....
Check out using Regular Expressions with the VBScript. You could pass the file name to the RegEx function and have it return the cleaned up version of what you want.
Check out using Regular Expressions with the VBScript. You could pass the file name to the RegEx function and have it return the cleaned up version of what you want.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- Phil Pendlebury
- Automation Wizard
- Posts: 543
- Joined: Tue Jan 16, 2007 9:00 am
- Contact:
Thanks Bob, I haven't a clue about VB script.
Still I can use Google like anyone else I guess...
Still I can use Google like anyone else I guess...
Phil Pendlebury - Linktree
- Phil Pendlebury
- Automation Wizard
- Posts: 543
- Joined: Tue Jan 16, 2007 9:00 am
- Contact:
Well this will have to do for me I guess. Not the most elegant solution but it will do:
Code: Select all
// ENTER DISALLOWED CHARACTERS
Let>notallowed=ENTER CHARS HERE FOR SOME REASON THIS FORUM WON'T ALLOW THEM TO BE ENTERED - COMMAS BRACKETS ETC.
Length>%notallowed%,naloop
// INPUT SOMETHING
Input>blah,DO IT!,Put some stuff here
// CHECK TO SEE IF DISALLOWED CHARS ARE IN INPUT
Let>rep=1
Repeat>rep
MidStr>%notallowed%,rep,1,isitthere
// FIND DISALLOWED AND IF ITS THERE REPLACE IT WITH UNDERSCORE
StringReplace>%blah%,isitthere,_,blah
Let>rep=rep+1
Until>rep>naloop
// SHOW RESULT
MsgModal>%blah%
Wait>10
Phil Pendlebury - Linktree