NSIS Home > NSIS Archive > NSIS Programmer's Reference
NSIS Programmer's Reference  

File Instruction

Adds file(s) to be extracted to the .

Syntax

File [/nonfatal] [/a] ((/r path) | filepattern) [...]) | (/oname=destname srcfile)

The File statement syntax has these parts:

Part Description
/nonfatal Optional. If this switch is used, a warning instead of an error will be generated when one or more specified files do not exist.
/a Optional. If this switch is used, the original attributes of the source files will be preserved.
/r Semi-optional. If this switch is used, the subdirectories of path and their contents is recursively added to the package.
path Semi-optional. Path specification of the path that contains the source files. It may have trailing wildcards (e.g. C:\mydir\*.*).
filepattern Semi-optional. File specification of the source files. This can be a single file, or more files by using wildcards.
/oname=destname Semi-optional. When this switch and parameter are used, the name of the file srcfile will be replaced by destname.
srcfile Semi-optional. File specification of the source file. No more than one file is allowed. Wildcards are prohibited.

Note

The output filename is \filename, where filename is the filename portion of the files specified by path or filepattern.

Remarks

If path is used with trailing wildcards (e.g. C:\mydir\*.*) and the /r switch is used, then the whole tree of path will go in \. If no trailing wildcards are used, the whole tree of path will go in \lastdir, where lastdir is the last directoryname path contains (e.g. \mydir).

The File statement sets the error flag if SetOverwrite try is used and the file could not be overwritten, or if SetOverwrite on is used, the file could not be overwritten and the user clicked the Ignore-button.

Examples

This example shows how to include the NSIS directory and it's subdirectories and contents into the package and extract it later to :

File /r "${NSISDIR}\*.*"

The following example includes multiple files into the package:

File "${NSISDIR}\Contrib\*.bmp" "${NSISDIR}\makensis.htm" "${NSISDIR}\Examples\*.*"

And this example includes makensis.htm, but extracts it as readme.html.

File /oname="readme.html" "${NSISDIR}\makensis.htm"

See also