Navigation: DocScript Reference > DocScript Functions >

Files and Directory Functions

 

 

 

 

Function

Description

[File.Copy](sourcefilename, destinationfilename, overwrite)

File copy function. The overwrite variable is optional, by default it is True.

 

Parameter(s)

sourcefilename - This can be any file on the system.

destinationfilename - The destination filename.

overwrite - Overwrite the file if it already exists.

[File.Exists](filename)

Determine whether a file exists. Returns True or False.

 

Parameter(s)

filename - This can be any file on the system.

[File.Move](sourcefilename, destinationfilename)

Moves a file from the source to destination locations.

 

Parameter(s)

sourcefilename - This can be any file on the system.

destinationfilename - The destination filename.

[File.Replace](sourcefilename, destinationfilename, backupfilename, ignoremetadataerrors)

Replaces the contents of the specified file with the contents of another file, deleting the original file and creating a backup of the replaced file and optionally ignores merged errors.

 

Parameter(s)

sourcefilename - This can be any file on the system.

destinationfilename - The destination filename.

backupfilename - TBD.

ignoremetadataerrors - TBD

[File.Delete](filename)

Deletes specified file.

 

Parameter(s)

filename - This can be any file on the system.

[File.DirectoryName](filename)

Returns files directory path.

 

Parameter(s)

filename - This can be any file on the system.

[File.Extension](filename, ignoreextenstion)

Returns the files extension. eg ".tif" ".pdf". IgnoreExtension is optional, by default it is False. If True the function will analyze the file contents to determine the extension.

 

Parameter(s)

filename - This can be any file on the system.

ignoreextenstion - Analyze the text in the filename or the content to get the extension.

[File.Length](filename)

Returns the length of the filename.

 

Parameter(s)

filename - This can be any file on the system.

[File.Name](filename)

Returns the filename, removing the path.


Parameter(s)

filename - This can be any file on the system.

[File.NameWoExt](filename)

Returns the name of the document without the path and extension.

 

Parameter(s)

filename - This can be any file on the system.

[File.ReadAllBytes](filename)

Reads the contents of file (binary).

 

Parameter(s)

filename - This can be any file on the system.

[File.ReadAllLines](filename)

Returns an array of lines.

 

Parameter(s)

filename - This can be any file on the system.

[File.ReadAllText](filename)

Returns a string of text.

 

Parameter(s)

filename - This can be any file on the system.

[File.WriteAllLines](filename, lines)

Writes all lines in an array of lines.

 

Parameter(s)

filename - This can be any file on the system.

lines - The array of text lines to be written.

[File.WriteAllText](filename, textstring)

Write a string of text.

 

Parameter(s)

filename - This can be any file on the system.

textstring - The text string to write to the file.

[File.AppendAllText](filename, textstring)

Appends the text to the specified file.

 

Parameter(s)

filename - This can be any file on the system.

textstring - The text string to append to the file text.

[File.CreatedDate](filename)

Returns the date the file was created.

 

Parameter(s)

filename - This can be any file on the system.

[File.ModifiedDate](filename)

Returns the date the file was modified.

 

Parameter(s)

filename - This can be any file on the system.

[File.AccessedDate](filename)

Returns the date the file was modified.

 

Parameter(s)

filename - This can be any file on the system.

[File.RenameOnDup](filename)

If file exists, then it will return a new filename with '_' and a sequence number appended.

 

Parameter(s)

filename - This can be any file on the system.

[File.DeleteAll](filename(s))

Deletes the list of files in the filename(s) parameter.

 

Parameter(s)

filename(s) - A list a filenames separated by a semi-colon.

[File.Locked](filename)

Checks whether the filename is locked. Returns 1 if locked, 0 if unlocked.

 

Parameter(s)

filename - This can be any file on the system.

[File.StripFF](filename)

Strips form-feeds from the file.

 

Parameter(s)

filename - This can be any file on the system.

[File.MD5Hash](filename)

Returns the MD5 hash of the file.

 

Parameter(s)

filename - This can be any file on the system.

 

 

[Dir.Create](directoryname)

Creates a directory.

 

Parameter(s)

directoryname - The name of the directory to create.

[Dir.Exists](directoryname)

Returns True if the directory exists, otherwise returns False.

 

Parameter(s)

directoryname - The name of the directory to check.

[Dir.GetDirectories](directoryname)

Gets the names of the directories (including their paths).

 

Parameter(s)

directoryname - The name of the directory to retrieve the sub-directories from.

[Dir.GetDirectories](directoryname, searchpattern)

Gets the names of the directories (including their paths) that match the specified search pattern in the current directory, and optionally searches all sub directories.

 

Parameter(s)

directoryname - The name of the directory to retrieve the sub-directories from.

searchpattern - The directory search pattern.

[Dir.GetDirectories](directoryname, searchpattern, all)

Returns an array of sub-directories below the directoryname directory that match the search pattern. If All is true will below the top-level sub-directories, otherwise will only search in the top-level.

 

Parameter(s)

directoryname - The name of the directory to retrieve the sub-directories from.

searchpattern - The search pattern.

all - Indicates whether to include sub-directories below the first level.

[Dir.GetFiles](directoryname)

Returns an array of files below the directoryname directory.

 

Parameter(s)

directoryname - The name of the directory to retrieve the file from.

[Dir.GetFiles](directoryname, searchpattern)

Returns an array of files below the directoryname directory that match the searchpattern.

 

Parameter(s)

directoryname - The name of the directory to retrieve the file from.

searchpattern - The search pattern of the files.

[Dir.GetFiles](directoryname, searchpattern, all)

Returns an array of files below the directoryname directory that match the searchpattern. If All is True will below the top-level files, otherwise will only search in the top-level.

 

Parameter(s)

directoryname - The name of the directory to retrieve the files from.

searchpattern - The search pattern.

all - Indicates whether to include sub-directories below the first level.

[Dir.Move](sourcedirectory, destinationdirectory)

Moves a directory and its contents to the destination.

 

Parameter(s)

sourcedirectory - The name of the directory to move.

destinationdirectory - The destination path.

 

 

 

 

Copyright © 2024 Portford Solutions Group, Inc.