Jump to content

Please help! I don't know where to start


Recommended Posts

Hi all,

I hope someone can help me get started with this script.

What i am doing now

I have an external hard drive with has a media player built in. it has no way of moving,copying or deleting any files within the player.

I want to plug it in and list of all the files on the drive.

I currently use

if not exist h:\bank30.rom pause
dir h:\*.avi /s/b/on > d:\lifeboxtemp.txt
type d:\lifeboxtemp.txt | find /v "Videos" > d:\lifebox.txt
rem type d:\lifeboxtemp.txt | find /v "Porn" > d:\lifebox.txt

in a .bat file.

this creates lifebox.txt so i can unplug the drive ant still edit the file.

Then i use 2 shortcuts to lifebox.txt and del_lifebox.txt to cut from 1 file and paste into the other file as i want to delete the file from the drive.

Then, next time i plug the drive in, i run the final file, "Delete from lifebox.au3" which has this script in it

#include <File.au3>

$filename = "d:\del_lifebox.txt"
$file = FileOpen($filename, 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Line read:", $line)
;   FileDelete($line)
    If Not FileDelete($line) Then
    MsgBox(4096,"Error", " Error Deleting the avi file.   error:" & @error)
    EndIf

Wend

FileClose($file)
;sleep(1000)

;If Not FileDelete($filename) Then
;  MsgBox(4096,"Error", " Error Deleting log.     error:" & @error)
;EndIf

If Not _FileCreate($filename) Then
   MsgBox(4096,"Error", " Error Creating/Resetting log.   error:" & @error)
EndIf

this reads the del_lifebox.txt file and deletes the files listed within it.

What i want to do

I want to combine all the above commands to a single script that has a box with buttons that runs each part if i click them.

One option is to read the contents of the drive and put it in a listbox which doesnt need the drive plugged in once its been scanned. I can then scan through the list at my leisure clicking on the left list and moving selected to the right list where it will be deleted next time the drive is plugged in.

Link to comment
Share on other sites

  • Moderators

happy2help,

1. Get all files from your drive into an array - use a recursive file lister (I have attached my version if you wish to use that).

2. Get that array into a list (listbox or listview) and choose the files to delete - look perhaps at GUICtrlCreateListView and _GUICtrlListView_GetHotItem.

3. Delete the selected files from your drive - you have this code pretty much done.

I hope that "helps [you] get started with this script".

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

  • 2 weeks later...

happy2help,

1. Get all files from your drive into an array - use a recursive file lister (I have attached my version if you wish to use that).

2. Get that array into a list (listbox or listview) and choose the files to delete - look perhaps at GUICtrlCreateListView and _GUICtrlListView_GetHotItem.

3. Delete the selected files from your drive - you have this code pretty much done.

I hope that "helps [you] get started with this script".

M23

Where is your version?

Can the array be put in a file for later use? and then retreived when i need it?

Link to comment
Share on other sites

  • Moderators

happy2help,

Here is the recursive file search again.

And for saving and reading arrays, look at _FileReadToArray and _FileWriteFromArray.

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...