1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Attributes in Win 98

Discussion in 'Legacy Windows' started by musicollector, 2003/10/26.

Thread Status:
Not open for further replies.
  1. 2003/10/26
    musicollector

    musicollector Inactive Thread Starter

    Joined:
    2003/04/04
    Messages:
    113
    Likes Received:
    1
    Using Win 98 SE.

    Why is it that when I apply or remove Read-only attribute on folders, it is not inherited by files (in various levels) contained therein? I know this is an explicit feature in W2K and XP, where I am actually asked if I need permissions filtered down. I have to go into each level and tediously apply the attribute. :(

    I hope someone can help. If there is a solution, I know this is where I can find it.

    Thanks.
     
    Last edited: 2003/10/26
  2. 2003/10/27
    gammaepsilon

    gammaepsilon Inactive

    Joined:
    2003/04/27
    Messages:
    267
    Likes Received:
    0
    This is not an omission in Win98SE - the concept hadn't been thought of at the time.

    The only recursive command that I am aware of is the DOS deltree where, given a folder, it will systematically delete all folders within and files within those folders.

    I have a home spun vbscript which cleans drives of zero byte files older than a given age and that, obviously, uses recursion. Since file attributes can be set in vbscript then one solution lies there. I'd need to rewrite it to start at a given folder rather than the root directory, strip the age code out and use a set atribute command rather than delete. I don't have the time at present to do that but if you are au fait with vbscript then you may like to have a crack at it.

    Someone else may have an alternative solution which they can post straight away.
     

  3. to hide this advert.

  4. 2003/10/27
    gammaepsilon

    gammaepsilon Inactive

    Joined:
    2003/04/27
    Messages:
    267
    Likes Received:
    0
    I'm a bit like BillyBob - couldn't wait.

    It didn't take as long as I thought it would.

    The following is a bare bones strip down of my zero byte script which has a pile of error checking and an input dialog. Cut, Paste into NotePad and save as AttribTree.vbs or whatever.

    --------------------------------------------

    Set fso=CreateObject( "Scripting.FileSystemObject ")

    TargetFolder= "e:\topfolder "
    Set FileSet=fso.GetFolder(TargetFolder).Files
    ConsiderFiles(FileSet)
    ConsiderFolders(TargetFolder)

    Sub ConsiderFiles(FileSet)
    Dim File
    For Each File In FileSet
    File.Attributes=1
    Next
    End Sub

    Sub ConsiderFolders(Folder)
    Dim F,SF,NewSF,FileSet
    Set F=fso.GetFolder(Folder)
    Set SF=F.SubFolders
    For Each Folder In SF
    Set FileSet=Folder.Files
    ConsiderFiles FileSet
    Set NewSf=fso.GetFolder(Folder)
    ConsiderFolders NewSF
    Next
    End Sub

    -------------------------------------------

    As it stands you will have to edit:

    "TargetFolder=" and "File.Attributes= "

    I created e:\topfolder within which I included some files and two subfolders viz One and Two and included files within them.

    With the above as is all the files had their attributes changed to read only.

    My next step would be to add code so that we could write something like:

    AttribTree.vbs Folder, Attributes

    where, in the above, Folder would be "e:\topfolder" and Attributes would be 1.

    I'd also add error checking code to make sure Folder existed and Attributes made sense and perhaps ask for confirmation if the system bit was set. I definitely have't got time to do that at the moment. Writing the bare bones is easy - making an app user friendly, as we used to say [don't see that much nowadays], and bullet proof takes ages.

    A caveat: If you have any qualms about using the above then my advice is DON'T. Some guys and gals here will have the above on board and giving it a pasting in no time but most will not touch it with a barge pole and they'd get no arguments from me.

    PS The folder attributes are left as is. To change them then 'Folder.Attributes=' will need to be inserted in the same position in the subroutine ConsiderFolders as 'File.Attributes' is in the subroutine ConsiderFiles. I've just tried this and it works OK. However, TargetFolder is not changed. I've just done a slight rewrite so that TragetFolder gets the same attributes. In this state we may be emulating your Win2000 and WinXP reference - I don't know as I've no experience with either - too poor :D
     
    Last edited: 2003/10/27
  5. 2003/10/27
    gammaepsilon

    gammaepsilon Inactive

    Joined:
    2003/04/27
    Messages:
    267
    Likes Received:
    0
    Not fair to leave you to insert if you're not into coding.

    Below will change the attributes of the target folder and everything within. There was no need for 'F=' in ConsiderFolders - one line will do.

    -------------------------------------------------

    Set fso=CreateObject( "Scripting.FileSystemObject ")

    ' Edit these two lines
    TargetFolder= "e:\topfolder "
    Attrib=1

    Set TFolder=fso.GetFolder(TargetFolder)
    TFolder.Attributes=Attrib
    Set FileSet=TFolder.Files
    ConsiderFiles(FileSet)
    ConsiderFolders(TargetFolder)

    Sub ConsiderFiles(FileSet)
    Dim File
    For Each File In FileSet
    File.Attributes=Attrib
    Next
    End Sub

    Sub ConsiderFolders(Folder)
    Dim SF,NewSF,FileSet
    Set SF=fso.GetFolder(Folder).SubFolders
    For Each Folder In SF
    Folder.Attributes=Attrib
    Set FileSet=Folder.Files
    ConsiderFiles FileSet
    Set NewSf=fso.GetFolder(Folder)
    ConsiderFolders NewSF
    Next
    End Sub

    ---------------------------------------------
     
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.