cavalli Posted July 16, 2013 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
water Posted July 16, 2013 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Solution UEZ Posted July 16, 2013 Solution 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Malkey Posted July 16, 2013 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)
cavalli Posted July 16, 2013 Author Posted July 16, 2013 Hello guys, thank you for your response. Thanks UEZ you gave me the solution it works!!
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