MakeFileList: Get files from dir: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author and download links, and changed format of some pages.)
m (Protected "MakeFileList: Get files from dir" ([edit=autoconfirmed] (expires 19:58, 23 August 2012 (UTC))))
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{PageAuthor|Afrow UK}}
== Description ==
== Description ==
This simple function written for [[user:WiLdWoLfStray|WiLdWoLfStray]] in [http://forums.winamp.com/showthread.php?threadid=209161 this forum topic] makes a list of files in a directory.
This simple function written for [[user:WiLdWoLfStray|WiLdWoLfStray]] in [http://forums.winamp.com/showthread.php?threadid=209161 this forum topic] makes a list of files in a directory.
Line 41: Line 43:
Pop $R1
Pop $R1
Pop $R0
Pop $R0
FunctionEnd </highlight-nsis>
FunctionEnd
</highlight-nsis>
-Stu
-Stu


Page author: [[User:Afrow UK|Afrow UK]]
[[Category:Disk, Path & File Functions]]

Latest revision as of 19:58, 23 May 2012

Author: Afrow UK (talk, contrib)


Description

This simple function written for WiLdWoLfStray in this forum topic makes a list of files in a directory.

Usage

Push "$INSTDIR\output.txt" # output file
Push "*.ext" # filter
Push "C:\A-Folder" # folder to search in
Call MakeFileList

The Function

Function MakeFileList
Exch $R0 #path
Exch
Exch $R1 #filter
Exch
Exch 2
Exch $R2 #output file
Exch 2
Push $R3
Push $R4
Push $R5
 ClearErrors
 FindFirst $R3 $R4 "$R0\$R1"
  FileOpen $R5 $R2 w
 
 Loop:
 IfErrors Done
  FileWrite $R5 "$R0\$R4$\r$\n"
  FindNext $R3 $R4
  Goto Loop
 
 Done:
  FileClose $R5
 FindClose $R3
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Pop $R0
FunctionEnd

-Stu