Hi,
I am using the following script to emuerate files within a top level folder (C:Test) and files within any subfolders underneath (e.g. C:TestSubfolder1…), and then change the read-only attribute on these files to off (if it exists in the firstplace).
The first part of the script works fine (i.e. any read-only files in C:Test are changed to read-only off), but the second part doesn’t work (i.e. read-only files within the subfolders stay as read-only). I don’t get any VB errors, it just doesn’t work correctly.
For clarification, I won’t know the names of the subfolders in C:Test, nor how many they are. I will also not know if any files exist in these subfolders, nor what their filenames are either.
Can anyone see where the second part of my script is going wrong?
SCRIPT STARTS **************************************************************************
Path1 = “C:Test”
Dim fso
Dim oFolder
Dim oFile
Dim oSubFolder
Set fso = createobject(“Scripting.FileSystemObject”)
‘ Set read-only attribute on files within C:Test to off
Set oFolder = fso.GetFolder(Path1)
For Each oFile In oFolder.Files
If oFile.Attributes And 1 Then
oFile.Attributes = oFile.Attributes – 1
End If
Next
‘ Set read-only attribute on files within subfolders within C:Test… to off
Set oFolder = fso.GetFolder(Path1)
Set colSubFolders = oFolder.SubFolders
Set colFiles = colSubFolders
For Each oFile In colFiles
If oFile.Attributes And 1 Then
oFile.Attributes = oFile.Attributes – 1
End If
Next
Set oSubFolder = Nothing
Set oFile = Nothing
Set oFolder = Nothing
Set fso = Nothing
SCRIPT END **************************************************************************
TIA and Merry Christmas!