Dryden Posted November 20, 2007 Share Posted November 20, 2007 Hi! Need some help guys! This is my problem: In my script I have a variable that leads to a path, for example how do I trim it to erase the path and it only shows the executable without \ and .exe for example: my variable at a given point might be: $var="c:\prog\prog.exe" or it could be $var="prog2.exe" what I'm looking for is for a way to transform it in $var="prog" or $var="prog2" thx in advance "Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." - Terry Pratchett. Link to comment Share on other sites More sharing options...
BrettF Posted November 20, 2007 Share Posted November 20, 2007 $string = "c:\prog\prog.exe" $split1 = StringSplit ($string, "\") $String = StringSplit ($split1[$split1[0]], ".") MsgBox (0, "", $String[1]) Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
jvanegmond Posted November 20, 2007 Share Posted November 20, 2007 Easier using multiple delimiters $string = "c:\prog\prog.exe" $String = StringSplit ($string, "\.") MsgBox (0, "", $String[$String[0]-2]) github.com/jvanegmond Link to comment Share on other sites More sharing options...
Dryden Posted November 20, 2007 Author Share Posted November 20, 2007 thx guys. that helped a lot! "Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." - Terry Pratchett. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now