Recursively Set Attributes on Files within Directories
Keywords: recursive set file attributes
This WinBatch script is useful for changing the attributes of all files in a folder and its sub folders to read write. This is useful when files are copied from a CD to a hard disk. Windows itself automatically sets file attributes to 'read only' when files are copied from CDs to other media. If these files need to be edited, the file attributes will need to be 'read write'. This script does that quickly for all the files within a folder. Just put attrset.wbt in that folder and run it from there.The extender is used to apply the settings to files in sub folders. This has many other applications.
;MODULO EXAMPLE strTitle = "Attribute Setter" strAskLineBoxPrompt = "Upper case sets, lower unsets attributes.%@CRLF%%@CRLF%R readonly, A archive, S system, H hidden%@CRLF%Note: A is set when file has NOT been backed up." strSetAttributes=AskLine(strTitle,strAskLineBoxPrompt,"r") strStartDirectory=AskLine(strTitle,"Enter a starting directory.","C:\temp") x=0 filea="" msg="This example will change files from %strStartDirectory% down." BoxOpen(strTitle,"%x% files changed.") Pause(" ",msg) AddExtender("wsrch34I.dll") ; This adds the text search extender. handle=srchInit(strStartDirectory,"*.*","","",16) dStart = TimeYMDHMS() while 1 filea=srchNext(handle) if filea=="" then break ; lower case r a s and h set to off the read only, archive, system ; and hidden attributes. Capitalized RASH sets the attributes. ; Only one attribute designation is required. The other three ; are optional. Change the "rash" to the setting you require. ; On archive bits: New files are created with the attribute bit ; A set to on. To reset all files to unbacked condition use ; this setting string: "A". That's right, just a capital A. FileAttrSet(filea,strSetAttributes) x=x+1 If x mod 10 == 0 Then BoxText("%x% files changed.") ;BoxText("%x% files changed.") endwhile dEnd = TimeYMDHMS() dDiff = TimeDiffSecs(dEnd,dStart) srchFree(handle) BoxShut() Delay(1) Message(strTitle,"%x% files changed.") Message(strTitle,"%dDiff% seconds elapsed.")
Article ID: W14496Filename: Recursively Set Attributes on Files.txt