Hello, I need to copy a folder and all it's files to a new location
for backup. How do I change the attributes of the destination
read-only files so I can overwrite them for the copy and then reset
the attribute after the copy?

Anyone?

Thanks.

Re: Change File Attributes by Bill

Bill
Fri Jul 04 11:20:49 CDT 2003

This came right out of the Windows script docs:
http://msdn.microsoft.com/scripting

Except I changed it for the Readonly bit
You'ld probably want to change it to
pass it a folder instead then toggle all
the files in the folder.

Function ToggleReadOnlyBit(filespec)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
If f.attributes and 1 Then
f.attributes = f.attributes - 1
ToggleReadOnlyBit= "ReadOnly bit is cleared."
Else
f.attributes = f.attributes + 1
ToggleReadOnlyBit= "ReadOnly bit is set."
End If
End Function

Bill Wallace

"Bioman" <azeem.mohammed@biovail.com> wrote in message
news:ca96a5fd.0307030811.3c6bbab3@posting.google.com...
> Hello, I need to copy a folder and all it's files to a new location
> for backup. How do I change the attributes of the destination
> read-only files so I can overwrite them for the copy and then reset
> the attribute after the copy?
>
> Anyone?
>
> Thanks.



Re: Change File Attributes by Michael

Michael
Fri Jul 04 13:21:10 CDT 2003

Bioman wrote:
> Hello, I need to copy a folder and all it's files to a new location
> for backup. How do I change the attributes of the destination
> read-only files so I can overwrite them for the copy and then reset
> the attribute after the copy?
>
> Anyone?

path = "c:\_temp"

set shell = createobject("wscript.shell")
cmd = "attrib " & path & "\*.* -r /S /D"
shell.run cmd,0,true



--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US

Technet Script Center
http://www.microsoft.com/technet/scriptcenter/default.asp

Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp


Re: Change File Attributes by Michael

Michael
Fri Jul 04 13:33:19 CDT 2003

A better version to handle paths with space...

path = "c:\some path with spaces"

set shell = createobject("wscript.shell")
cmd = "attrib """ & path & "\*.*"" -r /S /D"
shell.run cmd,0,true


--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US

Technet Script Center
http://www.microsoft.com/technet/scriptcenter/default.asp

Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp