Jump to content

How do you exclude a file type?


Recommended Posts

I had everything ready to go and now I learn my PST script needs to over-look a PST file that always has the same name, but is on a number of different servers. I looked in the help section but I could not find any command to over-look, exclude, ignore ect. the file. My script is below and works great:

;Local $sUserName = "Administrator"
;Local $sPassword = "SomePassword"
;RunAs($sUserName, @ComputerName, $sPassword, 0, @SystemDir)

#include <Array.au3>
#include "RecFileListToArray.au3"
PST()
Func PST()
    Local $aArray, $aDrives = DriveGetDrive("FIXED") ; Read the Help file about DriveGetDrive.
    If @error = 0 Then
        For $i = 1 To $aDrives[0]
            $aArray = _RecFileListToArray($aDrives[$i] & "", "*.pst", 1, 1, 0, 2)
            If @error Then
                ContinueLoop
            EndIf
            For $j = 1 To $aArray[0]
                ;ConsoleWrite("FileDelete(" & $aArray[$j] & ")" & @CRLF)
    FileDelete($aArray[$j])
            Next
        Next
EndIf

EndFunc   ;==>PST

If every server has a PST called "Batman.PST", how can I exclude that file and still remove the others?

Edited by RBrown1375
Link to comment
Share on other sites

  • Moderators

RBrown1375,

You should have posted in the RecFileListToArray thread, but now that you are here...:D

Just use the $sExclude_List parameter like this: ;)

$aArray = _RecFileListToArray($aDrives[$i] & "", "*.pst", 1, 1, 0, 2, "Batman.PST")

Or you could just ignore those files when you delete: :D

For $j = 1 To $aArray[0]
    If $aArray[$j] <> "Batman.PST Then
        FileDelete($aArray[$j])
    EndIf
Next

All clear? :)

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

I'll give this a try to both posts. Thank you!

Melba23,

The first solution you offered works fine, but I'm curious to know if there is a way to add another excluded file to that line? example:

$aArray = _RecFileListToArray($aDrives[$i] & "", "*.pst", 1, 1, 0, 2, "SomeName.PST" "SomeOtherName.PST")

I'm just covering my bases..... ;)

Cheers

Edited by RBrown1375
Link to comment
Share on other sites

  • Moderators

RBrown1375,

The first solution you offered works fine

As I wrote the UDF I should hope so! :D

but I'm curious to know if there is a way to add another excluded file to that line?

At times you wonder why you bother to write function headers explaining what the parameters mean....;)

You just need to separate the different masks with a semi-colon:

$sExclude_List - Optional: filter for excluded results (default ""). Multiple filters must be separated by ";"

All clear now? :)

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

I did read the headers and tried to write my code based on yours, but mine fails on the ";".

$aArray = _RecFileListToArray($aDrives[$i] & "", "*.pst", 1, 1, 0, 2, "SomeName.PST" )

If I run this example above, my script will protect the underlined file, but no others when I add code variations or the ";". I'll keep at it.

Thanks

Link to comment
Share on other sites

  • Moderators

RBrown1375,

The line should look like this:

$aArray = _RecFileListToArray($aDrives[$i] & "", "*.pst", 1, 1, 0, 2, "SomeName.PST;SomeOtherName.PST")

I have just tested it and it really does work. ;)

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

  • Moderators

RBrown1375,

Been there, done that! :)

No problem. ;)

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...