Jump to content

sundar

Active Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by sundar

  1. The script is already running as admin using #RequireAdmin. I had to delete those folders manually.
  2. In my programm i need to delete folders/files and show the user about progress. Though it can can easily be done with FileDelete and DirRemove (without progress), the problem comes when the folder/file size is larger.It hanges the main gui completely. I searched the forum and found a script which deletes files one by one. However the script does not work properly. It does not delete all the files and folders. Once the script complete then i have to provide admin rights to delete remaining folder/files. Here is the script i am trying to use:- $DIR = "path\to\folder" If Not @error Then $FILE = _FileListToArray($DIR) If IsArray($FILE) Then Dim $PATH[5] ProgressOn("Removing "& $SEARCH,$DIR) For $INDEX = 1 To $FILE[0] ProgressSet($INDEX*100/$FILE[0],$FILE[$INDEX]) _PathSplit($DIR & "\" & $FILE[$INDEX],$PATH[1],$PATH[2],$PATH[3],$PATH[4]) If $PATH[4] <> "" Then FileDelete($DIR & "\" & $FILE[$INDEX]) Else DirRemove($DIR & "\" & $FILE[$INDEX],1) EndIf Sleep(250) Next ProgressOff() EndIf EndIf I also need to remove the folder where $DIR points to.
  3. @careca Thank you for the script. It works well here too :-)
  4. Thanks for the reply. bsdtar does not show any progress. The only clue from the command line program however is that it can list all the files from archive.
  5. I need to extract iso file and /or other archieve formats to usb drive. When the extract process exisist the show the user progress of the process. For extraction i use windows version of bsdtar. The only idea i got is to calculate drive and iso size then create progress bar accordingly. But i am finding it difficult to get the progress bar properly. Code is given below.Any help is appriciated. Note: Please do not suggest me to use 7zip. #include <GUIConstants.au3> #include <GUIConstantsEx.au3> _PROGRESS () Func _PROGRESS () $Progress = GUICtrlCreateProgress(8, 56, 417, 25) $Form = GUICreate("Extracting File", 369, 128, 193, 126) GUISetState(@SW_SHOW) $Progress1 = GUICtrlCreateProgress(8, 56, 353, 17) $close = GUICtrlCreateButton("Close", 200, 88, 75, 25, 0) $start = GUICtrlCreateButton("Start", 80, 88, 75, 25, 0) $Dest = "J:\test\" Const $iTotal_Space = Round (DriveSpaceTotal ( "J:" )) Const $FILE_SIZE = FileGetSize ( "E:\archieve.iso") $iIsoSize = Round ($FILE_SIZE / 1048576) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $close ExitLoop Case $msg = $start $Extract = Run(@DesktopDir& '\bsdtar.exe -C J:\empty -xf E:\archieve.iso', "", @SW_HIDE) While ProcessExists($Extract) $iCurrentSize = Round (DriveSpaceFree( "J:" )) $iDummyValue = 15252 - $iCurrentSize $percentage = Round ((($iDummyValue / 280) *100 )) ConsoleWrite ($percentage) If $percentage > 0 And $percentage < 101 Then GUICtrlSetData($Progress1,$percentage) Sleep (3000) EndIf WEnd EndSelect WEnd EndFunc
  6. Just wanted to share you all that _FinfInFile is working now. The preoblem was with forum formating. I copied fresh function and it is working now. Though remaining questions not solved.
  7. You are too good. Your function does what it says. Thank you vermuch for the quick help. :-) If forum formating is an issue, then why don't you upload the UDF instead of just desplaying?
  8. I know this is old thread but the function is not working for me. I am trying to find the string "sundar" in files with *.txt extension in desktop directory. I don not know what went wrong but i did not change anything in the function. Iused only used example script with change in search string and file path/extension. The result of the function is attached.
  9. The link which you gave is again for listing files which i have already done it. I need to find if string in array exist in the files.
  10. Here is the sample of the content of a file(s):- string1 strin2 other-string some-other-string foo=bar string(n) I used _FileListToArrayEx to list all the files with specific extension. Now i am removing specific strings which are not required. I used _ReplaceStringInFile to delete specific string. Hoever i am struck while deleting the string "foo=bar" where "foo=" is common in some of the files and bar can be anything else. So my requirement is to either delete entire foo=bar or delete anything after foo= till white space is reached or insert some-static-string after foo= Any help is appriciated.
  11. I am trying to find all the .txt or files with specific extension and load the file path to array using "_FileListToArrayEx". The result was success and pretty good. I removed first row as it contain only number. The remaining array only contain link to files. secondly, I have got a list of strings in a different array set with following content $array[0] = string1 $array[1] = string2 $array[2] = string3 $array[3] = string4 $array[n] = stringn Now what i am trying to do is search each content of array through all the files. If the match is found then write the particular arry to the different .txt file. Here is the _FileListToArrayEx UDF i used for finding files with specific extension :- ; #FUNCTION# ======================================================================================================================== ; Name...........: _FileListToArray ; Description ...: Lists files and\or folders in a specified path (Similar to using Dir with the /B Switch) ; Syntax.........: _FileListToArray($sPath[, $sFilter = "*"[, $iFlag = 0]]) ; Parameters ....: $sPath - Path to generate filelist for. ; $sFilter - Optional the filter to use, default is *. (Multiple filter groups such as "All "*.png|*.jpg|*.bmp") Search the Autoit3 helpfile for the word "WildCards" For details. ; $iFlag - Optional: specifies whether to return files folders or both Or Full Path (add the flags together for multiple operations): ; |$iFlag = 0 (Default) Return both files and folders ; |$iFlag = 1 Return files only ; |$iFlag = 2 Return Folders only ; |$iFlag = 4 Search subdirectory ; |$iFlag = 8 Return Full Path ; Return values .: @Error - 1 = Path not found or invalid ; |2 = Invalid $sFilter ; |3 = Invalid $iFlag ; |4 = No File(s) Found ; Author ........: SolidSnake <MetalGX91 at GMail dot com> ; Modified.......: ; Remarks .......: The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Files\Folders returned ; $array[1] = 1st File\Folder ; $array[2] = 2nd File\Folder ; $array[3] = 3rd File\Folder ; $array[n] = nth File\Folder ; Related .......: ; Link ..........: ; Example .......: Yes ; Note ..........: Special Thanks to Helge and Layer for help with the $iFlag update speed optimization by code65536, pdaughe ; Update By DXRW4E ; =================================================================================================================================== Func _FileListToArrayEx($sPath, $sFilter = "*", $iFlag = 8) Local $hSearch, $sFile, $sFileList, $iFlags = StringReplace(BitAND($iFlag, 1) + BitAND($iFlag, 2), "3", "0"), $sSDir = BitAND($iFlag, 4), $FPath = "", $sDelim = "|", $sSDirFTMP = $sFilter $sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\" ; ensure single trailing backslash If Not FileExists($sPath) Then Return SetError(1, 1, "") If BitAND($iFlag, 8) Then $FPath = $sPath If StringRegExp($sFilter, "[\\/:><]|(?s)\A\s*\z") Then Return SetError(2, 2, "") If Not ($iFlags = 0 Or $iFlags = 1 Or $iFlags = 2 Or $sSDir = 4 Or $FPath <> "") Then Return SetError(3, 3, "") $hSearch = FileFindFirstFile($sPath & "*") If @error Then Return SetError(4, 4, "") Local $hWSearch = $hSearch, $hWSTMP = $hSearch, $SearchWD, $sSDirF[3] = [0, StringReplace($sSDirFTMP, "*", ""), "(?i)(" & StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace("|" & $sSDirFTMP & "|", '\|\h*\|[\|\h]*', "\|"), '[\^\$\(\)\+\[\]\{\}\,\.\]', "\\$0"), "\|([^\*])", "\|^$1"), "([^\*])\|", "$1\$\|"), '\*', ".*"), '^\||\|$', "") & ")"] While 1 $sFile = FileFindNextFile($hWSearch) If @error Then If $hWSearch = $hSearch Then ExitLoop FileClose($hWSearch) $hWSearch -= 1 $SearchWD = StringLeft($SearchWD, StringInStr(StringTrimRight($SearchWD, 1), "\", 1, -1)) ElseIf $sSDir Then $sSDirF[0] = @extended If ($iFlags + $sSDirF[0] <> 2) Then If $sSDirF[1] Then If StringRegExp($sFile, $sSDirF[2]) Then $sFileList &= $sDelim & $FPath & $SearchWD & $sFile Else $sFileList &= $sDelim & $FPath & $SearchWD & $sFile EndIf EndIf If Not $sSDirF[0] Then ContinueLoop $hWSTMP = FileFindFirstFile($sPath & $SearchWD & $sFile & "\*") If $hWSTMP = -1 Then ContinueLoop $hWSearch = $hWSTMP $SearchWD &= $sFile & "\" Else If ($iFlags + @extended = 2) Or StringRegExp($sFile, $sSDirF[2]) = 0 Then ContinueLoop $sFileList &= $sDelim & $FPath & $sFile EndIf WEnd FileClose($hSearch) If Not $sFileList Then Return SetError(4, 4, "") Return StringSplit(StringTrimLeft($sFileList, 1), "|") MsgBox(4096,"",$sFile) EndFunc and here is the code i used for deleting first row :- For $n = UBound($array) - 1 to 0 step -1 If IsInt ($array[$n]) Then ;= "2" Then _ArrayDelete($array, $n) EndIf Next I am struck hereater. Any help is appriciated. Meanwhile i used _FindinFile UDF written by guinness, but it did not give me any output. Attached screenshot shows the result of _FinfinFile. Even this UDF solution will also solve half of my problem.
  12. I have an application which delete folder and files specified by the user. Everthing workes fine but problem comes when the file/folder size is bigger(morethan 1GB). The GUI hangs when deleting large file/folder size. The idea is to have a progress bar with looping statement when deletion is in progress. So that looping stops the hanging of GUI and progress bar shows users to know about the process/progress. However i am unable to figureout how to detect deleting process. Thank you in advance.
  13. Thanks for the reply. That worked but in a seperate window. However i am trying to integrate the progress bar with in my GUI.
  14. I have been trying to do this for last 3 days but nothing seems to be working (correctly). What i am trying to do is extracting an iso image to my pendrive during which progress bar should show the process. The actual size of the archive size is not known but no significant difference is there after extraction. Here is my code and where am i making mistke? #include <GUIConstants.au3> #include <GUIConstantsEx.au3> _PROGRESS () Func _PROGRESS () $Progress = GUICtrlCreateProgress(8, 56, 417, 25) $Form = GUICreate("Copy File", 369, 128, 193, 126) GUISetState(@SW_SHOW) $Progress1 = GUICtrlCreateProgress(8, 56, 353, 17) $close = GUICtrlCreateButton("Close", 200, 88, 75, 25, 0) $start = GUICtrlCreateButton("Start", 80, 88, 75, 25, 0) $Source = "E:\archive.iso" $Dest = "K:\TEST\" Const $INITIAL_SIZE = DriveSpaceFree( "K:" ) Const $FILE_SIZE = FileGetSize ( $Source ) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $close ExitLoop Case $msg = $start $Extract = Run(@ScriptDir & '\7z.exe' & ' x "' & $Source & '" ' & "-y -o" & '"' & $Dest & '"', "", @SW_HIDE) Sleep (100) While ProcessExists($Extract) > 0 $SPACE_FREE = DriveSpaceFree( "K:" ) $percentage = Round((( DriveSpaceFree( "K:" ) - $INITIAL_SIZE ) * 100 / $FILE_SIZE), 0) If $percentage > 0 And $percentage < 101 Then GUICtrlSetData($Progress1,$percentage) EndIf WEnd EndSelect WEnd EndFunc Any help is appriciated.
  15. I am also in need of progressbar while 7zip extract archives. I tried the code posted here. It works but the progress reaches 100% even when actual extraction is taking place. Any help?
  16. Any help pls. I am not able to move ahead with out solving this issue.
  17. To be more specific i have shown the (trouble) function code below. The variable $FILE is actually created by the main program. Func ADD () If FileExists ( $FILE ) Then $EXT = "C:\Temp\temp" DirCreate ( $EXT ) Local $EXT_FILE $EXT_FILE = '7z.exe x' & " " & $FILE & " " & "-y -o" & $EXT & " " & 'file.txt' & " " & "-r" RunWait($EXT_FILE, "", @SW_HIDE) If FileExists ( $EXT & "\folder\file.txt" ) Then $Len = FileRead ( $EXT & "folder\file.txt" ) StringRegExp ( $Len , "string to search", 2, " " ) If @error = 0 Then MsgBox(4096,"", "Correct file found") EndIf EndIf DirRemove ( $EXT ) EndIf EndFunc ; ==> ADD
  18. Yup. That is typo error actual file name is 7z.exe. I tried to run the function inside first file but then also it does not produce any result.
  19. I am having an issue with executing function which are available in another file. Basically i have main script (file1) for GUI and another file (file 2) contain only functions (created by me). At the moment i have written three functions each will be executed while pressing buttons. Third function is not executing and dont know where i am making mistake. All three functions uses same variables, so i set all the variables as globle in file1. To test third function i included MsgBox after every line. Form the MsgBox out put i could see that there is no issue with variables but i am struck in this line $EXT_FILE = '7z.exe x' & " " & $ARCHIVE_FILE & " " & "-y -o" & $DESTINATION_FOLDER & " " & 'file.txt' & " " & "-r" RunWait($EXT_FILE, "", @SW_HIDE) 7z.exe is in script folder. If i provide variables $ARCHIVE_FILE & $DESTINATION_FOLDER directly and run file 2 then the function works with out an issue. Where am i making mistake?
  20. Your function is absolutily fine. It did not work after i changed it. Thanks for pointing out the mistake. I have solved it by using below command... Return RunWait('7z.exe' & ' x "' & $7z_File & '" ' & $7z_Password & "-y -o" & $7z_Folder & ' file.txt"' & '" ' & "-r" & '"', "", @SW_HIDE)
  21. Thank you for the quick reply. I got this function from this forum and tried to modify according to my need. But instead of extracting single file it created file.tx tfolder in the destination folder and extracted allfiles in to it. Here is the modified line from the function. Return RunWait('7za.exe' & ' x "' & $sZipFile & '" ' & $sPassword & "-o" & $sDestinationFolder & "file.txt" & "-r" & '"', "", @SW_HIDE)
×
×
  • Create New...