Old 5th October 2012, 17:08   #1
bytebucket
Junior Member
 
Join Date: Jul 2012
Posts: 6
How to use SetFileAttributes on multiple files (*.txt)

I'm installing a directory of files with the below. I don't know what files will be there, but the idea is to grab whatever files are there and put them into the install directory.

code:

SetOutPath "$INSTDIR\MyTextFiles"
File "${TEXTFILESFORINSTALLER}\*.txt"
SetOutPath "$INSTDIR"



I'd like to set the read-only attribute on these files. I found the SetFileAttributes command which looks like what I need. The problem is, it appears to only apply to a single file. Since I don't know what files will be there, I can't explicitly call it once for each file.

Any ideas? I need to call SetFileAttributes on all the .txt files in the directory.
bytebucket is offline   Reply With Quote
Old 6th October 2012, 18:58   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
http://forums.winamp.com/showthread.php?t=349039

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 9th October 2012, 11:41   #3
bytebucket
Junior Member
 
Join Date: Jul 2012
Posts: 6
Thanks, that worked! Here's what I used for reference.

code:

; set my text files as readonly
FindFirst $0 $1 "$INSTDIR\MyTextFiles\*.txt"
txtFilesReadOnlyLoop:
StrCmp $1 "" txtFilesReadOnlyLoopDone
SetFileAttributes "$INSTDIR\MyTextFiles\$1" FILE_ATTRIBUTE_READONLY
FindNext $0 $1
Goto txtFilesReadOnlyLoop
txtFilesReadOnlyLoopDone:
FindClose $0

bytebucket is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump