Attrib: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Updated author and download links, and changed format of some pages.) |
m (Updated author links.) |
||
Line 1: | Line 1: | ||
{|align=right | |||
|<small>Author: [[{{ns:2}}:sunjammer|sunjammer]] ([[{{ns:3}}:sunjammer|talk]], [[{{ns:-1}}:Contributions/sunjammer|contrib]])</small> | |||
|} | |||
<br style="clear:both;"> | |||
== Description == | == Description == | ||
A small NSIS script function written by Hendri Adriaens aka [[user:Smile2Me | Smile2Me]] that applies file attributes to many files at once. | A small NSIS script function written by Hendri Adriaens aka [[user:Smile2Me | Smile2Me]] that applies file attributes to many files at once. | ||
Line 63: | Line 67: | ||
Pop $1 | Pop $1 | ||
FunctionEnd</highlight-nsis> | FunctionEnd</highlight-nsis> | ||
Revision as of 23:14, 29 April 2005
Author: sunjammer (talk, contrib) |
Description
A small NSIS script function written by Hendri Adriaens aka Smile2Me that applies file attributes to many files at once.
Hendri said at the time "I created it for Eduardo R. Puntel. He created an installer that copies files from CD to harddisk and wanted the program to be able to edit all files after install. The script changes the FileAttribute of all files in a dir to a preset value. Edit the script a bit to customise to your required FileAttributes for the files. The script can be used as a workaround since
SetFileAttributes "DIR\*.*" NORMAL
does not work." I'm not sure if the comment about SetFileAttributes not working is still correct.
The Script
outfile attrib.exe name attrib ; Attrib ; ; Script to quickly set the FileAttribute ; of many files in a dir. ; ; Usage: ; Push "Dir" ; Call Attrib ; ; Notice that SetFileAttributes cannot take ; variables as "Attribute" so edit the script ; if you want some other attribute(s) to be ; assigned to the files. ; ; This might be a handy script when copying ; files from CD that need to be edited later. ; ; By: Hendri Adriaens ; HendriAdriaens@hotmail.com Section ; The demo zip includes two text-files. ; Check that they are "read-only" and ; then compile and run the script. Push $EXEDIR\prob Call Attrib Sectionend Function Attrib Exch $1 ; Dir Push $2 Push $3 FindFirst $2 $3 "$1\*.*" StrCmp $3 "" exitloop loop: StrCmp $3 "" exitloop StrCmp $3 "." next StrCmp $3 ".." next IfFileExists "$1\$3\*.*" next ; SetFileAttributes does not accept variables as attribute, ; so manually set this to the necessary value. SetFileAttributes "$1\$3" 0 next: FindNext $2 $3 Goto loop exitloop: FindClose $2 Pop $3 Pop $2 Pop $1 FunctionEnd