Jump to content

Search the Community

Showing results for tags '_filelisttoarrayrec()'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 2 results

  1. Please help me sort the directory tree by level. I want to sort the folders in order: 6-> 5> 4> 3> 2> 1 Thanks for all the help and suggestions! #include <File.au3> #include <Array.au3> Global Const $sRemotePath = '/user/trong/sync' Global Const $sLocalPath = @MyDocumentsDir _Sequential($sLocalPath, $sRemotePath) Func _Sequential($iLocalPath, $iRemotePath) $iLocalPath = StringReplace($iLocalPath, "/", "\") $iRemotePath = StringReplace($iRemotePath, "\", "/") If (StringRight($iLocalPath, 1) = "\") Then $iLocalPath = StringTrimRight($iLocalPath, 1) ConsoleWrite("> From: " & $iLocalPath & @CRLF) ConsoleWrite("> TO: " & $iRemotePath & @CRLF) Local $aDirList = _FileListToArrayRec($iLocalPath, '*', $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH) If (Not @error) And IsArray($aDirList) Then For $d = 1 To $aDirList[0] ConsoleWrite("! Current Path (" & $d & '/' & $aDirList[0] & '): ' & $aDirList[$d] & @CRLF) Local $aFileList = _FileListToArray($aDirList[$d], '*', $FLTA_FILES, False) If (Not @error) And IsArray($aFileList) Then For $f = 1 To $aFileList[0] ConsoleWrite("+ File: (" & $f & '/' & $aFileList[0] & ') ON Path ' & $d & '/' & $aDirList[0] & @CRLF) Local $iPathName = StringReplace($aDirList[$d], $iLocalPath & '\', '') Local $iFileName = _SplitPath($aFileList[$f], 5) Local $iRemoteDir = StringReplace($iRemotePath & '/' & $iPathName, '\', '/') Local $iRemoteFile = StringReplace($iRemoteDir & '/' & $iFileName, '\', '/') Local $iLocalFile = $aDirList[$d] & '\' & $iFileName ConsoleWrite("- Path Name : " & $iPathName & @CRLF) ConsoleWrite("- File Name : " & $iFileName & @CRLF) ConsoleWrite("- Remote Dir : " & $iRemoteDir & @CRLF) ConsoleWrite("- Remote File: " & $iRemoteFile & @CRLF) ConsoleWrite("- Local File : " & $iLocalFile & @CRLF) ;~ _FTP_DirCreate($iRemotePath & '\' & $iPathName) ;~ _FTP_ProgressUpload($hFTPSession, $aDirList[$d] & '\' & $iFileName, $iRemotePath & '\' & $iPathName) Next EndIf Next EndIf EndFunc ;==>_Sequential Func _IsFile($sPath) If Not FileExists($sPath) Then Return SetError(1, 0, -1) If StringInStr(FileGetAttrib($sPath), 'D') <> 0 Then Return SetError(0, 0, 0) ;IsDir Else Return SetError(0, 0, 1) ;IsFile EndIf EndFunc ;==>_IsFile Func _SplitPath($sFilePath, $sReturnType = 0) Local $sDrive, $sDir, $sFileName, $sExtension Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", 1) 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 $sFileName = $aArray[3] $sExtension = $aArray[4] If $sReturnType = 0 Then Return $aArray If $sReturnType = 1 Then Return $sDrive If $sReturnType = 2 Then Return $sDir If $sReturnType = 3 Then Return $sFileName If $sReturnType = 4 Then Return $sExtension Local $fName = $sFileName & $sExtension If $sReturnType = 5 Then Return $fName Local $zName = $sDrive & $sDir If $sReturnType = 6 Then Return $zName ; By Dao Van Trong - TRONG.LIVE EndFunc ;==>_SplitPath
  2. Why ? Source: #RequireAdmin #Region #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=y #EndRegion #include <Array.au3> #include <Constants.au3> #include <File.au3> ConsoleWrite("===================================================="&@CRLF) Global $Search_Key = "♡" ;~ Global $Search_Path = @ScriptDir & "\_Source\" Global $Search_Path = "A:\_Webs___\_Source\" Global $Search_FileType = '*.php;*.js;*.xml' Global $iReurn=_SearchInFile($Search_Key, $Search_Path, $Search_FileType) ConsoleWrite($iReurn & " - Error: " & @error & @CRLF) Func _SearchInFile($sSearch, $sFilePath, $sMask = '*', $fRecursive = 1, $fCaseSensitive = True) If (FileExists($sFilePath)<>1) Then Return SetError(-1, 0, 0) Else ConsoleWrite("- File " &$sFilePath&" is Exists !"& @CRLF) EndIf Local $aFileList = _FileListToArrayRec($sFilePath, $sMask, 0, $fRecursive, 1, 2) Local $iError = @error If $iError<>0 Or (IsArray($aFileList)<>1) Then Switch $iError Case 1 ConsoleWrite("! Error: 1 - Path not found or invalid" & @CRLF) Case 2 ConsoleWrite("! Error: 2 - Invalid Include parameter" & @CRLF) Case 3 ConsoleWrite("! Error: 3 - Invalid Exclude parameter" & @CRLF) Case 4 ConsoleWrite("! Error: 4 - Invalid Exclude_Folders parameter" & @CRLF) Case 5 ConsoleWrite("! Error: 5 - Invalid $iReturn parameter" & @CRLF) Case 6 ConsoleWrite("! Error: 6 - Invalid $iRecur parameter" & @CRLF) Case 7 ConsoleWrite("! Error: 7 - Invalid $iSort parameter" & @CRLF) Case 8 ConsoleWrite("! Error: 8 - Invalid $iReturnPath parameter" & @CRLF) Case 9 ConsoleWrite("! Error: 9 - No files/folders found" & @CRLF) EndSwitch Return SetError(1, 0, 0) EndIf For $i = 1 To UBound($aFileList) -1 Local $iFileContent = FileRead($aFileList[$i]) If StringInStr($iFileContent, $sSearch, $fCaseSensitive) Then ConsoleWrite($aFileList[$i] & @CRLF) EndIf Next EndFunc ;==>_SearchInFile ;~ Local $hTimer = TimerInit() ;~ Local $aArray = _FindInFile($SearchKey, $SearchPath, $SearchFileType) ; Search for 'findinfile' within the @ScripDir and only in .au3 & .txt files. ;~ ConsoleWrite(Ceiling(TimerDiff($hTimer) / 1000) & ' second(s)' & @CRLF) ;~ _ArrayDisplay($aArray) ;~ $hTimer = TimerInit() ;~ $aArray = _FindInFile('autoit', @ScriptDir, '*.au3') ; Search for 'autoit' within the @ScripDir and only in .au3 files. ;~ ConsoleWrite(Ceiling(TimerDiff($hTimer) / 1000) & ' second(s)' & @CRLF) ;~ _ArrayDisplay($aArray) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FindInFile ; Description ...: Search for a string within files located in a specific directory. ; Syntax ........: _FindInFile($sSearch, $sFilePath[, $sMask = '*'[, $fRecursive = True[, $fLiteral = Default[, ; $fCaseSensitive = Default[, $fDetail = Default]]]]]) ; Parameters ....: $sSearch - The keyword to search for. ; $sFilePath - The folder location of where to search. ; $sMask - [optional] A list of filetype extensions separated with ';' e.g. '*.au3;*.txt'. Default is all files. ; $fRecursive - [optional] Search within subfolders. Default is True. ; $fLiteral - [optional] Use the string as a literal search string. Default is False. ; $fCaseSensitive - [optional] Use Search is case-sensitive searching. Default is False. ; $fDetail - [optional] Show filenames only. Default is False. ; Return values .: Success - Returns a one-dimensional and is made up as follows: ; $aArray[0] = Number of rows ; $aArray[1] = 1st file ; $aArray[n] = nth file ; Failure - Returns an empty array and sets @error to non-zero ; Author ........: guinness ; Remarks .......: For more details: http://ss64.com/nt/findstr.html ; Example .......: Yes ; =============================================================================================================================== Func _FindInFile($sSearch, $sFilePath, $sMask = '*', $fRecursive = True, $fLiteral = Default, $fCaseSensitive = Default, $fDetail = Default) Local $sCaseSensitive = $fCaseSensitive ? '' : '/i', $sDetail = $fDetail ? '/n' : '/m', $sRecursive = ($fRecursive Or $fRecursive = Default) ? '/s' : '' If $fLiteral Then $sSearch = ' /c:' & $sSearch EndIf If $sMask = Default Then $sMask = '*' EndIf $sFilePath = StringRegExpReplace($sFilePath, '[\\/]+$', '') & '\' Local Const $aMask = StringSplit($sMask, ';') Local $iPID = 0, $sOutput = '', $sCMD = '' For $i = 1 To $aMask[0] $sCMD = 'findstr ' & $sCaseSensitive & ' ' & $sDetail & ' ' & $sRecursive & ' "' & $sSearch & '" "' & $sFilePath & $aMask[$i] & '"' ConsoleWrite("cmd: " & $sCMD & @CRLF) ;~ MsgBox(0,"",$sCMD) $iPID = Run(@ComSpec & ' /c ' & $sCMD, @SystemDir, @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($iPID) $sOutput &= StdoutRead($iPID) Next Return StringSplit(StringStripWS(StringStripCR($sOutput), BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)), @LF) EndFunc ;==>_FindInFile
×
×
  • Create New...