Jump to content

User71

Members
  • Posts

    5
  • Joined

  • Last visited

Community Answers

  1. User71's post in Deleting Hidden Folders listed in text file with DirRemove was marked as the answer   
    Thank you both for your replies, I will investigate further when I'm not being forced to Xmas shop!
    Thanks Saint for reminding me of the quotes, I will go through and change them when I can.
    And thanks Spider, never seen that function it looks interesting, I guess it would mainly change the DirRemove part of my code to look at the array with a nth variable to count the array entries? So DirRemove($Array [$nthEntry], 1)
    I forgot to add my dir line I'm running (which does work), just because I prepopulated the text files first this time as I was troubleshooting.
    I run this first normally but as said, I was trying to simplify to find the problem so I just made the C:List1.txt and put in   X:21New Folder   which becomes    "X:21New Folder"    in C:List2.txt.
    Local $DIRCMDPath = "X:\2\1" & " > " Local $HiddenDirPath = @MyDocumentsDir & "\SBackup\Logs\HiddenDir.txt" Local $DIRCMD = "dir /S /B /A:HD " & $DIRCMDPath & $HiddenDirPath Local $DetectHidden = Run(@ComSpec & " /c " & $DIRCMD, @WindowsDir, @SW_HIDE) Thanks
    EDIT
    I have successfully used Spider001 suggestion of an array in the following script, but it does give an error as seen below:
    #include <MsgBoxConstants.au3> #include <file.au3> #include <Array.au3> Array() Func Array() Global $Array = _FileListToArrayRec("X:\2\1", "*", $FLTAR_FOLDERS, 0, 0, $FLTAR_FULLPATH) If @error Then Exit _ArrayDisplay($Array, "Display all first level folders with full path") EndFunc ;==>Array Local $nth = 1 While 1 $FileAttr = FileGetAttrib($Array[$nth]) If StringInStr($FileAttr, "H") Or StringInStr($FileAttr, "S") Then DirRemove($Array[$nth], 1) EndIf $nth = $nth + 1 If $FileAttr = "" Then ExitLoop WEnd "X:\Software\AutoIT\Tutorial Tests\TestSpacev2.au3" (16) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $FileAttr = FileGetAttrib($Array[$nth]) $FileAttr = FileGetAttrib(^ ERROR The script does work, but it wants to go on to FileGetAttrib from a non existent part of the array which I think is the cause of the error, e.g. trying to access $array[4] when only $array[0] to [3] exists.
    Any suggestions to solve the error? If so I think it might be case closed
    EDIT
    Think I managed to sort it; feel free to suggest a neater way though:
    Global $input2_data = Somepath $DirGetSizeArray = DirGetSize($Input2_Data, 3) Local $ArrayFolders = _FileListToArrayRec($Input2_Data, "*", $FLTAR_FOLDERS, 0, 0, $FLTAR_FULLPATH) _ArrayDisplay($ArrayFolders, "Display no hidden or system folders") If IsArray($ArrayFolders) Then Global $ArraySize = UBound($ArrayFolders) - 1 EndIf Local $nth = 1 While 1 If $DirGetSizeArray[2] = 0 Then ExitLoop $FileAttr = FileGetAttrib($ArrayFolders[$nth]) If StringInStr($FileAttr, "H") Or StringInStr($FileAttr, "S") Then DirRemove($ArrayFolders[$nth], 1) EndIf If $nth = $ArraySize Then ExitLoop $nth = $nth + 1 WEnd Local $ArrayFiles = _FileListToArrayRec($Input2_Data, "*", $FLTAR_FILES, 0, 0, $FLTAR_FULLPATH) _ArrayDisplay($ArrayFiles, "Display no hidden or system files") If IsArray($ArrayFiles) Then Global $ArraySize = UBound($ArrayFiles) - 1 EndIf Local $nth = 1 While 1 If $DirGetSizeArray[1] = 0 Then ExitLoop $FileAttr = FileGetAttrib($ArrayFiles[$nth]) If StringInStr($FileAttr, "H") Or StringInStr($FileAttr, "S") Then FileSetAttrib($ArrayFiles[$nth], "-SHRA") FileDelete($ArrayFiles[$nth]) EndIf If $nth = $ArraySize Then ExitLoop $nth = $nth + 1 WEnd
×
×
  • Create New...