Jump to content

Progressbar for file/folder delete to stop GUI hang


Recommended Posts

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.

Link to comment
Share on other sites

#RequireAdmin from help file?

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

I would use Melba's "RecFileListToArray" since it can retrieve files and folders,

you can specify the depth of the recursive function and some more stuff. Maybe the script lags

because while it is deleting the big file it doesn't update the bar, same as saying it just hangs.

Someone with higher knowledge step in and prove me wrong.

EDIT: Oh btw add DirRemove($DIR,1) after the NEXT, that way,

after it has found and deleted all files, it deletes the folder itself uppon exiting the loop.

Next
DirRemove($DIR,1)
ProgressOff()
Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • 2 years later...

Are you importing any other AU3 files in your script. Because this script is not working for me.

Ans also please tell if you got solution for this.

 

Getting error @  $SEARCH and _PathSplit() as undefined global variable and function respectively.

 

Please see the attached screenshot for reference.

Untitled.png

Edited by ur
more info
Link to comment
Share on other sites

  • Moderators

ur,

Stop necroing every thread you can find about deletion progress bars - I have deleted all the others.

As to your question about _PathSplit - why not look in the Help file and find out what include file you need for yourself?

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

These scripts might be helpful.

For me , delete2.au3 is working, as I tested only it.

 

Delete1.au3

Delete2.au3

Delete3.au3

 

But the issues is not solved as the script hangs when deleting large files.

 

The below script is used by me before for copying files/folders with progress bar(windows default one).

I found similar option for moving by using same object.

But not able to find for delete.

Can anyone provide for deleting.

 

dml.vbs

Edited by ur
more info
Link to comment
Share on other sites

ur,

Stop necroing every thread you can find about deletion progress bars - I have deleted all the others.

As to your question about _PathSplit - why not look in the Help file and find out what include file you need for yourself?

M23

 

​@Melba23

I am not waiting for these kind of sarcastic answers.Everyone in the forum knows about the help file.

I am waiting for other people in forum who are willing to help.

And more over if anyone write any piece of code in the forum, it doesn't mean that reader should investigate himself to get the dependency.It is only matter of two lines to show the #include lines in the post to save others time.

 

Edited by ur
S
Link to comment
Share on other sites

  • Moderators

ur,

I am not waiting for these kind of sarcastic answers

​Neither am I - and I suggest that you pay attention to what I said.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

FileDelete and DirRemove will not return to the running script until they have finished deleting what you told them to, there's no workaround possible using those functions. You could do it using a Run command and the RMDIR command and/or the DEL commands from a console window, but you'd have to get feedback from those commands to determine if they've done what you wanted.

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 Gude
How 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...