Rofellos Posted December 23, 2010 Share Posted December 23, 2010 These functions are very useful if you got a file path and want the name or the directory of the file. expandcollapse popup; #FUNCTION# ====================================================================================================== ; Name...........: GetDir ; Description ...: Returns the directory of the given file path ; Syntax.........: GetDir($sFilePath) ; Parameters ....: $sFilePath - File path ; Return values .: Success - The file directory ; Failure - -1, sets @error to: ; |1 - $sFilePath is not a string ; Author ........: Renan Maronni <renanmaronni@hotmail.com> ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ================================================================================================================== Func GetDir($sFilePath) Local $aFolders = StringSplit($sFilePath, "\") Local $iArrayFoldersSize = UBound($aFolders) Local $FileDir = "" If (Not IsString($sFilePath)) Then Return SetError(1, 0, -1) EndIf $aFolders = StringSplit($sFilePath, "\") $iArrayFoldersSize = UBound($aFolders) For $i = 1 To ($iArrayFoldersSize - 2) $FileDir &= $aFolders[$i] & "\" Next Return $FileDir EndFunc ;==>GetDir ; #FUNCTION# ====================================================================================================== ; Name...........: GetFileName ; Description ...: Returns the file name of the given file path ; Syntax.........: GetFileName($sFilePath) ; Parameters ....: $sFilePath - File path ; Return values .: Success - The file name ; Failure - -1, sets @error to: ; |1 - $sFilePath is not a string ; Author ........: Renan Maronni <renanmaronni@hotmail.com> ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =================================================================================================================== Func GetFileName($sFilePath) Local $aFolders = "" Local $FileName = "" Local $iArrayFoldersSize = 0 If (Not IsString($sFilePath)) Then Return SetError(1, 0, -1) EndIf $aFolders = StringSplit($sFilePath, "\") $iArrayFoldersSize = UBound($aFolders) $FileName = $aFolders[($iArrayFoldersSize - 1)] Return $FileName EndFunc ;==>GetFileName ahmeddzcom 1 Link to comment Share on other sites More sharing options...
MrCreatoR Posted December 23, 2010 Share Posted December 23, 2010 There is already _PathSplit UDF, and also look at my _PathSplitByRegExp() udf. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
Rofellos Posted December 23, 2010 Author Share Posted December 23, 2010 (edited) There is already _PathSplit UDF, and also look at my _PathSplitByRegExp() udf.Yes, but with _PathSplit you have to concatenate the items of the array to get de full directory every time. And I use it a lot. So I made a function to reduce the work. _PathSplit and _PathSplitByRegExp are actually much more versatile. But some times I need something more specific. Edited December 23, 2010 by Rofellos Link to comment Share on other sites More sharing options...
MrCreatoR Posted December 23, 2010 Share Posted December 23, 2010 with _PathSplit you have to concatenate the items of the array to get de full directory every timeNope: Dim $szDrive, $szDir, $szFName, $szExt _PathSplit(@ScriptFullPath, $szDrive, $szDir, $szFName, $szExt) ConsoleWrite($szDrive & $szDir & @LF) _PathSplit and _PathSplitByRegExp are actually much more versatile. But some times I need something more specific.Then here is a simple way for your functions: Func GetDir($sFilePath) If Not IsString($sFilePath) Then Return SetError(1, 0, -1) EndIf Local $FileDir = StringRegExpReplace($sFilePath, "\\[^\\]*$", "") Return $FileDir EndFunc Func GetFileName($sFilePath) If Not IsString($sFilePath) Then Return SetError(1, 0, -1) EndIf Local $FileName = StringRegExpReplace($sFilePath, "^.*\\", "") Return $FileName EndFunc Marcelos 1 Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
Rofellos Posted December 23, 2010 Author Share Posted December 23, 2010 Nope: Dim $szDrive, $szDir, $szFName, $szExt _PathSplit(@ScriptFullPath, $szDrive, $szDir, $szFName, $szExt) ConsoleWrite($szDrive & $szDir & @LF) Then here is a simple way for your functions: Func GetDir($sFilePath) If Not IsString($sFilePath) Then Return SetError(1, 0, -1) EndIf Local $FileDir = StringRegExpReplace($sFilePath, "\\[^\\]*$", "") Return $FileDir EndFunc Func GetFileName($sFilePath) If Not IsString($sFilePath) Then Return SetError(1, 0, -1) EndIf Local $FileName = StringRegExpReplace($sFilePath, "^.*\\", "") Return $FileName EndFunc Yes, thanks! Marcelos 1 Link to comment Share on other sites More sharing options...
michaelslamet Posted December 25, 2012 Share Posted December 25, 2012 @Rofellos: thanks for this GetDir and GetFileName function. I sucessfully use it Link to comment Share on other sites More sharing options...
TheSaint Posted December 26, 2012 Share Posted December 26, 2012 (edited) The only element missing from _PathSplit, is just the parent foldername, which funnily enough I always seem to require.Obviously that's for the name of the folder containing a file - without any path elements.Perhaps _PathSplit should be amended to ->_PathSplit(@ScriptFullPath, $szDrive, $szPath, $szDir, $szFName, $szExt) Edited December 26, 2012 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
guinness Posted December 26, 2012 Share Posted December 26, 2012 What's wrong with $szDrive & $szDir? If not then provide an example of what you expect from _PathSplit. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
TheSaint Posted December 27, 2012 Share Posted December 27, 2012 (edited) I haven't got an install of AutoIt on this machine, so I can't whip up a quick example, that I might make a little error in somewhere manually, but basically ->C:Program FilesMP3 ToolsMp3TagMp3Tag GUI.exeWith _PathSplit you get ->$szDrv = C:$szDir = Program FilesMP3 ToolsMp3Tag$szFName = Mp3Tag GUI$szExt = .exeThere is no parent folder name for the file, in this case ->Mp3TagTo get that, you have to strip the rest away each time.In my view, it should be ->$szDrv = C:$szPth = Program FilesMP3 Tools$szDir = Mp3Tag$szFName = Mp3Tag GUI$szExt = .exeAll sorts of scenarios require just the parent folder name on it's own ... at least for me, they do.Essentially, it's the program name in many scenarios, where the executable may be named something else.EDITOf course, in many cases, the $szPth element would have to cope with returning a blank.C:Mp3TagMp3Tag GUI.exe Edited December 27, 2012 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
Rux Posted December 27, 2012 Share Posted December 27, 2012 I've made some functions that do this as well. Link to comment Share on other sites More sharing options...
TheSaint Posted December 27, 2012 Share Posted December 27, 2012 (edited) I've made some functions that do this as well.As have many of us no doubt, but share away if you like.Old codgers like me precede the _PathSplit command, and have often used Functions at hand, and this may be why no one to my knowledge has asked for that improvement.If I was up on UDF protocols and cared enough, I would have added the improvement myself years ago. This topic brought it to mind, and I thought I'd mention the missing element ... that I've never understood why it was left out.At a guess, I'd have to say, that I strip away a path for that element more than any other, so it's always been passing strange that it was missing from _PathSplit.In a sense, it's very much like using _PathSplit twice, to get what you want._PathSplit(@ScriptFullPath, $szDrive, $szDir, $szFName, $szExt)$progname = szDrive & $szDir_PathSplit($progname, $szDrive, $szDir, $szFName, $szExt)$progname = $szFNameBut then of course you lose the original $szDir & $szFName & $szExt elements unless you store them as other variables. Edited December 27, 2012 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
BrewManNH Posted December 27, 2012 Share Posted December 27, 2012 I think that the way _PathSplit returns things the way they do is because sometimes all you have is just a drive letter and a folder name. I think it wouldn't make much sense to return the folder name twice if your file is in, for example, C:Temp, you'd get the Temp part twice. The way it is now, it's a simple matter to use the last backslash in the $szDir as the indicator of the folder name that the path points to. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
guinness Posted December 27, 2012 Share Posted December 27, 2012 (edited) I care about the UDFs hence why I asked. I can't see any real need to add this as you have to look from the perspective of would this benefit everyone and not just me. Secondly it would be a massive script breaking change, especially if you consider the first part again of whether it would benefit the majority and the language, which the likes of the Word/Excel UDF updates are doing. Edited December 27, 2012 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
TheSaint Posted December 27, 2012 Share Posted December 27, 2012 (edited) I think that the way _PathSplit returns things the way they do is because sometimes all you have is just a drive letter and a folder name. I think it wouldn't make much sense to return the folder name twice if your file is in, for example, C:Temp, you'd get the Temp part twice.No different than what happens now with $szDir, if the file is in the root of a drive. You code it to only return what is remaining, so I can't see it as that difficult or troublesome.The way it is now, it's a simple matter to use the last backslash in the $szDir as the indicator of the folder name that the path points to.As I have been doing.@guinness - You no doubt know more of the ins & outs of the function than I do, so would know the difficulty involved, plus as you say, script breaking for older scripts and different to what people are used to, but I've seen that happen many times over the years with AutoIt ... and probably most other languages.I'm just so surprised that the element wasn't thought of and implemented in the first place, first time around. Has always felt like an oversight to me.Surely I'm not the only one that feels this way, or has wished it was included.I've created hundreds of programs over the years, and nearly every single one, I've had to use the backslash, which costs another line or two of code each time. I'm not fussed to keep doing it that way though, it's just I've always been bewildered by its lack of inclusion, since someone went to all the trouble of creating _PathSplit ... it just seems so incomplete without it, and negates (for me) half the reason for using _PathSplit in the first place.Perhaps I do things differently to others in this regard ... though I seriously doubt that.Short of asking a user to type in a program name, it has to be something we all need to get, quite often?EDITOf course, one way around most of the issues, is to create a new named function, based on the _PathSplit one, that has the missing element, plus a couple more that would be handy.i.e. _PathSections or _PathElements_PathSections(@ScriptFullPath, $szDrive, $szPath, $szFilepath, $szDir, $szFile, $szFName, $szExt)So for ->C:Program FilesMP3 ToolsMp3TagMp3Tag GUI.exeyou get ->$szDrive = C:$szPath = Program FilesMP3 Tools$szFilepath = C:Program FilesMP3 ToolsMp3Tag$szDir = Mp3Tag$szFile = Mp3Tag GUI.exe$szFName = Mp3Tag GUI$szExt = .exeThat way, there is no mucking around with extra code to get what you want. Edited December 27, 2012 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
guinness Posted December 27, 2012 Share Posted December 27, 2012 script breaking for older scripts and different to what people are used to, but I've seen that happen many times over the years with AutoIt ... and probably most other languages.It could be argued that those script breaking changes were beneficial to all and not just a select few.If there was a need for it then someone by now would have posted a 'feature request' in Trac. If you feel this will benefit not just you but other users, then by all means post a feature request in Trac. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
TheSaint Posted December 27, 2012 Share Posted December 27, 2012 (edited) It could be argued that those script breaking changes were beneficial to all and not just a select few.I find it very hard to believe that it would only benefit a few. Most might not care, and have kept quiet about it for years like I have, but I'm sure they would use it regularly if it was there ... or are you telling me it's a rare thing to get the program name for a file from the path?If there was a need for it then someone by now would have posted a 'feature request' in Trac. If you feel this will benefit not just you but other users, then by all means post a feature request in Trac.Like I said, I suspect people have just not bothered, they have an alternate way to do things, that may cost a few more lines of code, but is simple/quick enough to employ. And frankly, I mentioned the whole thing, knowing I would just get the response I did, and for once, thought what the heck. Others would be less motivated.Hence, I doubt I'll bother with Trac, not unless a few come on board with me here.That's not to say it shouldn't have always been there though, to benefit all.How you can imagine it would only benefit me, I just don't understand? Edited December 27, 2012 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
guinness Posted December 27, 2012 Share Posted December 27, 2012 (edited) And frankly, I mentioned the whole thing, knowing I would just get the response I did, and for once, thought what the heck. Others would be less motivated.Update _PathSplit with your additions and lets see what the response is. I'm more than happy to add your update if there is a need, but I personally can't see it.How you can imagine it would only benefit me, I just don't understand?Because I can't see the real need for _PathSplit to retrieve the parent folder. But as I said I'm more than happy to discuss with others if they feel it would be beneficial.I get the impression you think I'm arguing, but not at all. I would love to add tons of additions to the UDFs, but in doing so I could not only create hassle for other users, but my reputation and access could be revoked. I only know of water, Mat and me out of the MVPs who are updating the UDFs and help file, so maybe they have a different take on this? Edited December 27, 2012 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
AZJIO Posted December 27, 2012 Share Posted December 27, 2012 _FO_PathSplitIn each case, you can change for the sake of speed of execution. My other projects or all Link to comment Share on other sites More sharing options...
TheSaint Posted December 27, 2012 Share Posted December 27, 2012 _FO_PathSplitIn each case, you can change for the sake of speed of execution.I'm not sure why you linked to that, because from what I read, it's even more limiting than the original _PathSplit and solves nothing?We are after the name of the folder, that the file is in, not the file.@guinness - You may not be arguing, but your response was exactly like I suspected, and not what I hoped. And please don't take that personally, because I'm sure most of the other AutoIt team members would have responded in the same way.I admit, that I was hoping for support from the general user population, if I expected anything, and won't proceed any further without that. Long experience here has taught me that, at least.But frankly if nothing ever gets said, then change rarely ever happens.I pipe up every now and then (like I did once again with Titlecase), just to give my support to promoting change of view.Further to all that, I'm not terribly fussed. If I genuinely cared deeply about this, then I would have amended the function for myself years ago, just like I did with _Propercase/Titlecase, but I haven't bothered ... because it's no big problem for me.That has no bearing though on what I think should be or my disappointment that others can't see the benefit to all.EDITAs a side note. I can remember when _PathSplit was first introduced, and some of the bugs it had, like not coping with a period in a folder name. It seemed poorly implemented to me, and not well thought out, so I avoided it for quite some time. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
guinness Posted December 27, 2012 Share Posted December 27, 2012 WinAPIEx has an array of functions that do a safer job than _PathSplit in my humble opinion. Oh, and I was about to amend _PathSplit as an example, but it appears I don't need to anymore. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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