cavalli Posted July 16, 2013 Share Posted July 16, 2013 (edited) Hello, I have basic knowledge of AutoIt3 and I looked at this forum very often for my codes, but is a first time that i make a new topic, so i'm new on this forum, and before ask for help I want just thank people who spend their time to answer questions and help newbies like me I do not know if the topic title is clear to you, let me explain my problem : I have a combobox that points to a folder, in the folder I have text files, when I choose one of these text files, I want the name of the file is assigned to a variable, but without the extension, for example the "mytxtfile.txt" file, I just want to retrieve in my variable "mytxtfile" Hopefully I was clear in my topic Edited July 16, 2013 by cavalli Link to comment Share on other sites More sharing options...
water Posted July 16, 2013 Share Posted July 16, 2013 Welcome to AutoIt and the forum! Please have a look at function _PathSplit. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Solution UEZ Posted July 16, 2013 Solution Share Posted July 16, 2013 (edited) Here some variants for filename only: $sText = "mytxtfile.txt" $way1 = StringLeft($sText, StringInStr($sText, ".", 0, -1) - 1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $way1 = ' & $way1 & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $way2 = StringTrimRight($sText, StringLen($sText) - StringInStr($sText, ".", 0, -1) + 1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $way2 = ' & $way2 & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $way3 = StringRegExpReplace($sText, "(.*)\..*", "$1") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $way3 = ' & $way3 & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $way4 = StringRegExp($sText, "(.*)\..*", 3) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $way4 = ' & $way4[0] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console It's not clear whether you have a full path string or only the filename! Br, UEZ Edited July 16, 2013 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Malkey Posted July 16, 2013 Share Posted July 16, 2013 And here is some string manipulation. ; Returns filename only without extension. Local $sFileName = "mytxtfile.txt" Local $sFullPathFileName = "c:\Dir\full path\mytxtfile.txt" ConsoleWrite(StringRegExpReplace($sFileName, "(.*\\|\..*)", "") & @LF) ConsoleWrite(StringRegExpReplace($sFullPathFileName, "(.*\\|\..*)", "") & @LF) Link to comment Share on other sites More sharing options...
cavalli Posted July 16, 2013 Author Share Posted July 16, 2013 Hello guys, thank you for your response. Thanks UEZ you gave me the solution it works!! 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