Jump to content

How Do I? _FileReadToArray Two Files to One Line?


Recommended Posts

So once again I'm working to develop a little something to help our field techs backup users profiles.

I've run into a little snag due to my limited knowledge and I'm reaching out to you guys

I need to set the attribute to some folders of the restored users data to hidden, I know how to do that

the problem I'm having is that I'm trying to read two files, the first is BackedUpUsers which contains a list of the users that were backed up, the second is SetHidden which has a list of the of the folders I need hidden,

What I would like to do is read from the BackedUpUsers list and maintain the username while the second part chews through the SetHidden file until it reaches the end of the file and then starts with the second user in the BackedUpUsers list... etc.. etc...

E.G.

BackedUsersList contains users john.smith and joe.public

SetHidden has AppData, Application Data and NetHood

I would like to run 

SetFileAttrib('c:\users\' & $BACKEDUPUSER & '\' & $SETHIDDEN', '+H')

this way it will do the following

c:usersjohn.smithAppData 

c:usersjohn.smithApplication Data

c:usersjohn.smithNetHood

Hope I've explained myself well enough to get a little help!

Link to comment
Share on other sites

  • Moderators

Elephant007,

Just use nested loops - loop through the users but inside that, loop through the folders. :)

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

Hi Elephant007,

  That does sound like fun !  :)   I think I got it...

Have a look at Melbas excellent RecFileListToArray. Can be set to only show folders.

That will get all your folders into an array, from there you can loop through them with your setFileAttr function.

Bill

edit: was going to post a link but... see dragon santas sig o:)

Edited by billo
Link to comment
Share on other sites

Thank you both for your suggestions

Melba23, this is what I ended up doing, is this what you suggested? Maybe it's a little rough, you know how I do

#Include <File.au3>

Local $aFile,$aInput,$bFile,$bInput
$aFile='SetHidden'
$bFile='BackedUpUser'

        _FileReadToArray($bFile, $bInput)
        For $b = 1 to UBound($bInput) -1
        _FileReadToArray($aFile,$aInput)
        For $a = 1 to UBound($aInput) -1
            FileSetAttrib('"\\' & @ComputerName & '\c$\users\'&$bInput[$b]&'\'&$aInput[$a]&'"','+H')
        Next
    Next
Link to comment
Share on other sites

  • Moderators

Elephant007,

Close, but just read the files once before you begin the loops: ;)

#include <File.au3>

Local $aFile, $aInput, $bFile, $bInput
$aFile = 'SetHidden'
$bFile = 'BackedUpUser'

_FileReadToArray($bFile, $bInput)
_FileReadToArray($aFile, $aInput)

For $b = 1 To UBound($bInput) - 1
    For $a = 1 To UBound($aInput) - 1
        FileSetAttrib('"\\' & @ComputerName & '\c$\users\' & $bInput[$b] & '\' & $aInput[$a] & '"', '+H')
    Next
Next
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...