Trong Posted April 16, 2017 Posted April 16, 2017 (edited) Need help to make function better with full infomation expandcollapse popup#include <Array.au3> #include <File.au3> _TEST(@ScriptFullPath) _TEST("A:") _TEST("A:\B.c") _TEST("D:\E\F\") _TEST("G:\H/../J.k/") _TEST("M:\N\k..J.k") _TEST("D:\E\F\..\G\G\I..J.K.M") Func _TEST($sFilePath) Local $sDrive = "", $sFullPathDir = "", $sDirPath = "", $sDirName = "", $sFileName = "", $sFileNameExt = "", $sExtension = "", $sExt = "" Local $aPathSplit = _PathSplitByRef($sFilePath, $sDrive, $sFullPathDir, $sDirPath, $sDirName, $sFileName, $sFileNameExt, $sExtension, $sExt) ConsoleWrite("!Path IN : " & $sFilePath & @CRLF) ; C:\Windows\System32\etc\hosts.exe ConsoleWrite("- Driver : " & $sDrive & @CRLF) ; C: ConsoleWrite("- DirPath : " & $sFullPathDir & @CRLF) ; C:\Windows\System32\etc\etc ConsoleWrite("- DirPath : " & $sDirPath & @CRLF) ; \Windows\System32\etc\ ConsoleWrite("- DirName : " & $sDirName & @CRLF) ; etc ConsoleWrite("- FileName : " & $sFileName & @CRLF) ; hosts ConsoleWrite("- FileNameExt: " & $sFileNameExt & @CRLF) ; hosts.exe ConsoleWrite("- Extension : " & $sExtension & @CRLF) ; .exe ConsoleWrite("- Ext : " & $sExt & @CRLF & @CRLF) ; exe ;~ ConsoleWrite("!Path IN : " & $aPathSplit[0] & @CRLF) ; C:\Windows\System32\etc\hosts.exe ;~ ConsoleWrite("- Driver : " & $aPathSplit[1] & @CRLF) ; C: ;~ ConsoleWrite("- DirPath : " & $aPathSplit[2] & @CRLF) ; C:\Windows\System32\etc\etc ;~ ConsoleWrite("- DirPath : " & $aPathSplit[3] & @CRLF) ; \Windows\System32\etc\ ;~ ConsoleWrite("- DirName : " & $aPathSplit[4] & @CRLF) ; etc ;~ ConsoleWrite("- FileName : " & $aPathSplit[5] & @CRLF) ; hosts ;~ ConsoleWrite("- FileNameExt: " & $aPathSplit[6] & @CRLF) ; hosts.exe ;~ ConsoleWrite("- Extension : " & $aPathSplit[7] & @CRLF) ; .exe ;~ ConsoleWrite("- Ext : " & $aPathSplit[8] & @CRLF) ; exe ;~ _ArrayDisplay($aPathSplit, "_PathSplit of " & $sFilePath) EndFunc ;==>_TEST Func _PathSplitByRef($sFilePath, ByRef $sDrive, ByRef $sFullPathDir, ByRef $sDirPath, ByRef $sDirName, ByRef $sFileName, ByRef $sFileNameExt, ByRef $sExtension, ByRef $sExt) If StringInStr($sFilePath,"..") Then $sFilePath=_PathFull($sFilePath) Local $aPartOfPath=StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $STR_REGEXPARRAYMATCH) ;~ If @error Then ReDim $aPartOfPath[9] ;~ $aPartOfPath[0] = $sFilePath ;~ EndIf $aPartOfPath[0] = $sFilePath ; C:\Windows\System32\etc\hosts.exe $sDrive = $aPartOfPath[1] ; C: $sFullPathDir = $aPartOfPath[1] & $aPartOfPath[2] ; C:\Windows\System32\etc If StringLeft($aPartOfPath[2], 1) == "/" Then $sDirPath = StringRegExpReplace($aPartOfPath[2], "\h*[\/\\]+\h*", "\/") Else $sDirPath = StringRegExpReplace($aPartOfPath[2], "\h*[\/\\]+\h*", "\\") EndIf $aPartOfPath[2] = $sFullPathDir ; C:\Windows\System32\etc $sDirName=StringReplace($sDirPath,"\","") $sDirName=StringReplace($sDirPath,"/","") $sFileName = $aPartOfPath[3] ; hosts $aPartOfPath[5] = $sFileName ; hosts $sExtension = $aPartOfPath[4] ; .exe $aPartOfPath[7] = $sExtension ; .exe $aPartOfPath[3] = $sDirPath ; \Windows\System32\etc\ $aPartOfPath[4] = $sDirName ; etc $aPartOfPath[6] = $sFileName & $sExtension ; hosts.exe $sFileNameExt = $aPartOfPath[6] ; hosts.exe $sExt = StringReplace($sExtension,".","") ; exe $aPartOfPath[8] = $sExt ; exe Return $aPartOfPath EndFunc ;==>_PathSplitByRef Edited April 16, 2017 by Trong code Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
Trong Posted April 16, 2017 Author Posted April 16, 2017 Same ; #FUNCTION# ==================================================================================================================== ; Author ........: Valik ; Modified.......: DXRW4E - Re-wrote to use a regular expression; guinness - Update syntax and structure. ; =============================================================================================================================== Func _PathSplit($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFileName, ByRef $sExtension) Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $STR_REGEXPARRAYMATCH) If @error Then ; This error should never happen. ReDim $aArray[5] $aArray[0] = $sFilePath EndIf $sDrive = $aArray[1] If StringLeft($aArray[2], 1) == "/" Then $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\/") Else $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\\") EndIf $aArray[2] = $sDir $sFileName = $aArray[3] $sExtension = $aArray[4] Return $aArray EndFunc ;==>_PathSplit but need 10 minutes ago, Trong said: make working and better Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
InunoTaishou Posted April 16, 2017 Posted April 16, 2017 (edited) Not sure I understand working and better when it literally does everything you're asking us to try and figure out..... #include <Array.au3> #include <File.au3> Global $sDrive, $sDir, $sFileName, $sExtension _ArrayDisplay(_PathSplit(@ScriptFullPath, $sDrive, $sDir, $sFileName, $sExtension)) _ArrayDisplay(_PathSplit("A:", $sDrive, $sDir, $sFileName, $sExtension)) _ArrayDisplay(_PathSplit("A:\B.c", $sDrive, $sDir, $sFileName, $sExtension)) _ArrayDisplay(_PathSplit("D:\E\F\", $sDrive, $sDir, $sFileName, $sExtension)) _ArrayDisplay(_PathSplit("G:\H/../J.k/", $sDrive, $sDir, $sFileName, $sExtension)) _ArrayDisplay(_PathSplit("M:\N\k..J.k", $sDrive, $sDir, $sFileName, $sExtension)) _ArrayDisplay(_PathSplit("D:\E\F\..\G\G\I..J.K.M", $sDrive, $sDir, $sFileName, $sExtension)) Edited April 16, 2017 by InunoTaishou
Trong Posted April 16, 2017 Author Posted April 16, 2017 _PathSplit() : $sFilePath, $sDrive, $sDir, $sFileName, $sExtension _PathSplitNEW(): $sFilePath, $sDrive, $sFullPathDir, $sDirPath, $sDirName, $sFileName, $sFileNameExt, $sExtension, $sExt Add: $sFullPathDir, $sDirName, $sFileNameExt, $sExt Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
InunoTaishou Posted April 16, 2017 Posted April 16, 2017 (edited) $sFullPathDir is [0] (Unless you mean full path without the file then it's [1] & [2]) $sDirName is [2] unless you mean the last folder the file is in. In which case you can get that using StringTrimLeft, StringRight, or StringMid $sFileNameExt and $sExt are [4] #include <Array.au3> #include <File.au3> Global $sDrive, $sFullPathDir, $sDir, $sFolder, $sFileName, $sExtension _ArrayDisplay(_PathSplitEx(@ScriptFullPath, $sDrive, $sFullPathDir, $sDir, $sFolder, $sFileName, $sExtension)) _ArrayDisplay(_PathSplitEx("A:", $sDrive, $sFullPathDir, $sDir, $sFolder, $sFileName, $sExtension)) _ArrayDisplay(_PathSplitEx("A:\B.c", $sDrive, $sFullPathDir, $sDir, $sFolder, $sFileName, $sExtension)) _ArrayDisplay(_PathSplitEx("D:\E\F\", $sDrive, $sFullPathDir, $sDir, $sFolder, $sFileName, $sExtension)) _ArrayDisplay(_PathSplitEx("G:\H/../J.k/", $sDrive, $sFullPathDir, $sDir, $sFolder, $sFileName, $sExtension)) _ArrayDisplay(_PathSplitEx("M:\N\k..J.k", $sDrive, $sFullPathDir, $sDir, $sFolder, $sFileName, $sExtension)) _ArrayDisplay(_PathSplitEx("D:\E\F\..\G\G\I..J.K.M", $sDrive, $sFullPathDir, $sDir, $sFolder, $sFileName, $sExtension)) Func _PathSplitEx($sPath, ByRef $sDrive, ByRef $sFullPathDir, ByRef $sDir, ByRef $sFolder, ByRef $sFileName, ByRef $sExtension) Local $aReturn = _PathSplit($sPath, $sDrive, $sDir, $sFileName, $sExtension) $sFullPathDir = $aReturn[1] & $aReturn[2] $sFolder = StringRight($aReturn[2], StringLen($aReturn[2]) - StringInStr($aReturn[2], "\", 0, -2)) _ArrayInsert($aReturn, 2, $sFullPathDir) _ArrayInsert($aReturn, 4, $sFolder) Return $aReturn EndFunc Edited April 16, 2017 by InunoTaishou
Trong Posted April 16, 2017 Author Posted April 16, 2017 (edited) I want it better and use StringRegExp, your code too long expandcollapse popup#include <Array.au3> #include <File.au3> _TEST("C:\Windows\System32\etc\hosts.exe") _TEST("A:") _TEST("A:\B.c") _TEST("D:\E\F\") _TEST("G:\H/../J.k/") _TEST("M:\N\k..J.k") _TEST("D:\E\F\..\G\G\I..J.K.M") Func _TEST($sFilePath) Local $sDrive, $sDir, $sFileName, $sExtension, $sFullPathDir, $sDirName, $sFileNameExt, $sExt Local $aPathSplit = _PathSplitByRef($sFilePath, $sDrive, $sDir, $sFileName, $sExtension, $sFullPathDir, $sDirName, $sFileNameExt, $sExt) _ArrayDisplay($aPathSplit, "_PathSplit of " & $sFilePath) EndFunc ;==>_TEST Func _PathSplitByRef($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFileName, ByRef $sExtension, ByRef $sFullPathDir, ByRef $sDirName, ByRef $sFileNameExt, ByRef $sExt) Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $STR_REGEXPARRAYMATCH) ;~ If @error Then ; This error should never happen. ReDim $aArray[9] $aArray[0] = $sFilePath ;~ EndIf $sDrive = $aArray[1] If StringLeft($aArray[2], 1) == "/" Then $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\/") $sDirName = StringReplace(StringRight($sDrive & $sDir, StringInStr($sDrive & $sDir, "\") + 1), "/", "") Else $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\\") $sDirName = StringReplace(StringRight($sDrive & $sDir, StringInStr($sDrive & $sDir, "\") + 1), "\", "") EndIf $aArray[2] = $sDir $sFileName = $aArray[3] $sExtension = $aArray[4] $sFullPathDir = $sDrive & $sDir $aArray[5] = $sFullPathDir $aArray[6] = $sDirName $sFileNameExt = $sFileName & $sExtension $aArray[7] = $sFileNameExt $sExt = StringReplace($sExtension, ".", "") $aArray[8] = $sExt Return $aArray EndFunc ;==>_PathSplitByRef Edited April 16, 2017 by Trong ... Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
InunoTaishou Posted April 16, 2017 Posted April 16, 2017 My code's too long...? It's 4 extra lines... Well maybe one of the more experienced RegEx experts can help you out then. Just know that in some instances, using String* functions are actually faster than a StringRegExp call.
Trong Posted April 17, 2017 Author Posted April 17, 2017 (edited) Your function working too slow! UDF it's not just 4 lines! TEST SPEED: Start process SpitPath1....Done on: 27804.4166587552 Start process SpitPath2....Done on: 116759.591921566 expandcollapse popup#include <Array.au3> #include <File.au3> Local $sFileList = @TempDir & "\~FileListALL.txt" If Not FileExists($sFileList) Then ConsoleWrite("Get file list....") Local $StartTimeGetListFile = TimerInit() Local $aFileList = _FileListToArrayRec(@HomeDrive&"\", "*.*", 0, 1, 1, 2) Local $EndTimeGetListFile = TimerDiff($StartTimeGetListFile) ConsoleWrite("Done on: " & $EndTimeGetListFile & @CRLF) ConsoleWrite("Wrting file list!") Local $StartTimeSaveListFile = TimerInit() Local $sFileContent For $i = 1 To $aFileList[0] - 1 $sFileContent &= $aFileList[$i] & @CRLF Next Local $sFileOpen = FileOpen($sFileList, 2) FileWrite($sFileOpen, $sFileContent) FileClose($sFileOpen) Local $EndTimeSveListFile = TimerDiff($StartTimeSaveListFile) ConsoleWrite("Done on: " & $EndTimeSveListFile & @CRLF) EndIf ConsoleWrite("Start process SpitPath1....") Local $StartTimeProcess = TimerInit() Local $aFileList = FileReadToArray($sFileList) For $i = 0 To UBound($aFileList) - 1 _TEST1($aFileList[$i]) Next Local $EndTimeProcess = TimerDiff($StartTimeProcess) ConsoleWrite("Done on: " & $EndTimeProcess & @CRLF) ConsoleWrite("Start process SpitPath2....") Local $StartTimeProcess = TimerInit() Local $aFileList = FileReadToArray($sFileList) For $i = 0 To UBound($aFileList) - 1 _TEST2($aFileList[$i]) Next Local $EndTimeProcess = TimerDiff($StartTimeProcess) ConsoleWrite("Done on: " & $EndTimeProcess & @CRLF) Func _TEST1($sFilePath) Local $sDrive, $sDir, $sFileName, $sExtension, $sFullPathDir, $sDirName, $sFileNameExt, $sExt Local $aPathSplit = _PathSplitByRef($sFilePath, $sDrive, $sDir, $sFileName, $sExtension, $sFullPathDir, $sDirName, $sFileNameExt, $sExt) ;~ _ArrayDisplay($aPathSplit, "_PathSplit of " & $sFilePath) EndFunc ;==>_TEST1 Func _TEST2($sFilePath) Local $sDrive, $sFullPathDir, $sDir, $sFolder, $sFileName, $sExtension Local $aPathSplit = _PathSplitEx($sFilePath, $sDrive, $sFullPathDir, $sDir, $sFolder, $sFileName, $sExtension) EndFunc ;==>_TEST2 Local $sDrive, $sFullPathDir, $sDir, $sFolder, $sFileName, $sExtension Func _PathSplitEx($sPath, ByRef $sDrive, ByRef $sFullPathDir, ByRef $sDir, ByRef $sFolder, ByRef $sFileName, ByRef $sExtension) Local $aReturn = _PathSplit($sPath, $sDrive, $sDir, $sFileName, $sExtension) $sFullPathDir = $aReturn[1] & $aReturn[2] $sFolder = StringRight($aReturn[2], StringLen($aReturn[2]) - StringInStr($aReturn[2], "\", 0, -2)) _ArrayInsert($aReturn, 2, $sFullPathDir) _ArrayInsert($aReturn, 4, $sFolder) Return $aReturn EndFunc ;==>_PathSplitEx Func _PathSplitByRef($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFileName, ByRef $sExtension, ByRef $sFullPathDir, ByRef $sDirName, ByRef $sFileNameExt, ByRef $sExt) Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $STR_REGEXPARRAYMATCH) ;~ If @error Then ; This error should never happen. ReDim $aArray[9] $aArray[0] = $sFilePath ;~ EndIf $sDrive = $aArray[1] If StringLeft($aArray[2], 1) == "/" Then $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\/") $sDirName = StringReplace(StringRight($sDrive & $sDir, StringInStr($sDrive & $sDir, "\") + 1), "/", "") Else $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\\") $sDirName = StringReplace(StringRight($sDrive & $sDir, StringInStr($sDrive & $sDir, "\") + 1), "\", "") EndIf $aArray[2] = $sDir $sFileName = $aArray[3] $sExtension = $aArray[4] $sFullPathDir = $sDrive & $sDir $aArray[5] = $sFullPathDir $aArray[6] = $sDirName $sFileNameExt = $sFileName & $sExtension $aArray[7] = $sFileNameExt $sExt = StringReplace($sExtension, ".", "") $aArray[8] = $sExt Return $aArray EndFunc ;==>_PathSplitByRef Edited April 17, 2017 by Trong CODE Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
InunoTaishou Posted April 17, 2017 Posted April 17, 2017 Slight modification makes my Ex function only a few milliseconds slower than yours (using 22,061 files to split) Func _PathSplitEx($sPath, ByRef $sDrive, ByRef $sFullPathDir, ByRef $sDir, ByRef $sFolder, ByRef $sFileName, ByRef $sExtension) Local $aReturn = _PathSplit($sPath, $sDrive, $sDir, $sFileName, $sExtension) $sFullPathDir = $aReturn[1] & $aReturn[2] $sFolder = StringRight($aReturn[2], StringLen($aReturn[2]) - StringInStr($aReturn[2], "\", 0, -2)) Return StringSplit($sPath & "|" & $sDrive & "|" & $sFullPathDir & "|" & $sDir & "|" & $sFolder & "|" & $sFileName & "|" & $sExtension, "|", $STR_NOCOUNT) EndFunc ;==>_PathSplitEx _ArrayInsert has a large overhead. In a real world practice it would never be noticed, since, honestly, no one is going to call _PathSplit thousands of times in a row. Creating a new string and returning the split version increases the call substantially. And, looks a hell of a lot cleaner. czardas 1
Trong Posted April 17, 2017 Author Posted April 17, 2017 Anyway thank you for your interest and reply! For me speed and simplicity are always given priority. I will try to learn to optimize code more. A program does not just use a single function. If you work with computers/VPS with low profile you will see the difference. expandcollapse popup#include <Array.au3> #include <File.au3> Local $sFileList = @TempDir & "\~FileListALL.txt" ;~ Local $sFileList = @TempDir & "\~FileListTMPA.txt" If Not FileExists($sFileList) Then ConsoleWrite("-Get file list....") Local $StartTimeGetListFile = TimerInit() ;~ Local $aFileList = _FileListToArrayRec(@HomeDrive & "\", "*.*", 0, 1, 1, 2) ;~ Local $aFileList = _FileListToArrayRec(@AppDataCommonDir & "\", "*.*", 0, 1, 1, 2) Local $EndTimeGetListFile = TimerDiff($StartTimeGetListFile) ConsoleWrite("Done on: " & $EndTimeGetListFile & @CRLF) ConsoleWrite("-Wrting file list!") Local $StartTimeSaveListFile = TimerInit() Local $sFileContent For $i = 1 To $aFileList[0] - 1 $sFileContent &= $aFileList[$i] & @CRLF Next Local $sFileOpen = FileOpen($sFileList, 2) FileWrite($sFileOpen, $sFileContent) FileClose($sFileOpen) Local $EndTimeSveListFile = TimerDiff($StartTimeSaveListFile) ConsoleWrite("Done on: " & $EndTimeSveListFile & @CRLF) EndIf ConsoleWrite("+Read data ....") Local $StartTimeRead = TimerInit() Local $aFileList = FileReadToArray($sFileList) Local $EndTimeRead = TimerDiff($StartTimeRead) ConsoleWrite("Done on: " & $EndTimeRead & @CRLF) ConsoleWrite("-Start process SpitPath1....") Global $sDrive, $sDir, $sFileName, $sExtension, $sFullPathDir, $sDirName, $sFileNameExt Local $StartTimeProcess = TimerInit() For $i = 0 To UBound($aFileList) - 1 _TEST1($aFileList[$i]) Next Local $EndTimeProcess = TimerDiff($StartTimeProcess) ConsoleWrite("Done on: " & $EndTimeProcess & @CRLF) ConsoleWrite("-Start process SpitPath2....") Global $sDrive, $sFullPathDir, $sDir, $sFolder, $sFileName, $sExtension Local $StartTimeProcess = TimerInit() For $i = 0 To UBound($aFileList) - 1 _TEST2($aFileList[$i]) Next Local $EndTimeProcess = TimerDiff($StartTimeProcess) ConsoleWrite("Done on: " & $EndTimeProcess & @CRLF) Func _TEST1($sFilePath) ;~ Local $aPathSplit = Return _PathSplitByRef($sFilePath, $sDrive, $sDir, $sFileName, $sExtension, $sFullPathDir, $sDirName, $sFileNameExt) ;~ _ArrayDisplay($aPathSplit, "_PathSplit of " & $sFilePath) EndFunc ;==>_TEST1 Func _TEST2($sFilePath) ;~ Local $aPathSplit = Return _PathSplitEx($sFilePath, $sDrive, $sFullPathDir, $sDir, $sFolder, $sFileName, $sExtension) EndFunc ;==>_TEST2 Func _PathSplitEx($sPath, ByRef $sDrive, ByRef $sFullPathDir, ByRef $sDir, ByRef $sFolder, ByRef $sFileName, ByRef $sExtension) Global $aReturn = _PathSplit($sPath, $sDrive, $sDir, $sFileName, $sExtension) $sFullPathDir = $aReturn[1] & $aReturn[2] $sFolder = StringRight($aReturn[2], StringLen($aReturn[2]) - StringInStr($aReturn[2], "\", 0, -2)) Return StringSplit($sPath & "|" & $sDrive & "|" & $sFullPathDir & "|" & $sDir & "|" & $sFolder & "|" & $sFileName & "|" & $sExtension, "|", $STR_NOCOUNT) EndFunc ;==>_PathSplitEx Func _PathSplitByRef($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFileName, ByRef $sExtension, ByRef $sFullPathDir, ByRef $sDirName, ByRef $sFileNameExt) Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $STR_REGEXPARRAYMATCH) ;~ If @error Then ; This error should never happen. ReDim $aArray[8] $aArray[0] = $sFilePath ;~ EndIf $sDrive = $aArray[1] If StringLeft($aArray[2], 1) == "/" Then $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\/") $sDirName = StringReplace(StringRight($sDrive & $sDir, StringInStr($sDrive & $sDir, "\") + 1), "/", "") Else $sDir = StringRegExpReplace($aArray[2], "\h*[\/\\]+\h*", "\\") $sDirName = StringReplace(StringRight($sDrive & $sDir, StringInStr($sDrive & $sDir, "\") + 1), "\", "") EndIf $aArray[2] = $sDir $sFileName = $aArray[3] $sExtension = $aArray[4] $sFullPathDir = $sDrive & $sDir $aArray[5] = $sFullPathDir $aArray[6] = $sDirName $sFileNameExt = $sFileName & $sExtension $aArray[7] = $sFileNameExt Return $aArray EndFunc ;==>_PathSplitByRef Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
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