Script

FTP

The professional tool to automate FTP, SFTP, FTPS

and schedule FTP batch jobs

Syntax:

ADDEXCLUSION(list,filename_or_directory)

  • list: ScriptFTP keeps two exclusion lists: one for uploads (with local files that are excluded from uploading) and another one for downloads (with remote files that are excluded when downloading). Use this parameter to indicate which list you want to add the file to. Allowed values for this parameter are:

    LOCAL

    Use this one to select the local exclusion list. This list stores local files that will be excluded when uploading.

    REMOTE

    Use this one to select the remote exclusion list. This list stores remote files that will be excluded when downloading.

  • filename_or_directory: the name of the filename or directory to exclude. If it is a directory put a / or \ at the end of the name. It can optionally include the path of the file or directory you want to exclude. The path must be a full path, for example “C:\Docs\Whatever.txt” or “/remote_dir/whatever/”. If you do not supply a path ScriptFTP will ignore all files or directories matching the name regardless of their path. For example “file.zip” will exclude any file named “file.zip” regardless of its location in the folder tree

Remarks:

  • This command is capable of ignoring directories as well. Use “/” or “\” at the end of the file name to indicate that it is a directory. See the examples.
  • This command supports wildcards. You can use a wildcard expression in the file name parameter, for example: “*.JPG” for ignoring all jpeg files. Note that file names on FTP servers are usually case sensitive; for example, *.jpg and *.JPG refer to different file extensions.

See also:

SYNC
GETFILE
PUTFILE
CLEAREXCLUSION

Examples:

# ignore any .exe file when downloading, regardless on its location
ADDEXCLUSION(REMOTE,"*.exe")
 
# ignore any exe file under /testing/joe_results/*.exe
ADDEXCLUSION(REMOTE,"/testing/joe_results/*.exe")
 
# ignore any directory named "backup" when downloading
# regardless on its location in the folder tree
ADDEXCLUSION(REMOTE,"backup/")
 
# ignore the directory "backup" in the root directory when downloading
ADDEXCLUSION(REMOTE,"/backup/")
 
# ignore the file named "backup.zip" located in the root directory when downloading
ADDEXCLUSION(REMOTE,"/backup.zip")
 
# ignore any file named "backup.zip" when downloading
# regardless of its location in the folder tree
ADDEXCLUSION(REMOTE,"backup.zip")
 
# ignore the folder named "backup" under /123/abc/
ADDEXCLUSION(REMOTE,"/123/abc/backup/")
 
# ignore any folder which name starts with "New folder"
# when downloading. Regardless of its location
ADDEXCLUSION(REMOTE,"New folder*/")
 
# Download everything except what is included in the
# download exclusion list
GETFILE("*.*",SUBDIRS)
# ignore any .exe file when downloading
ADDEXCLUSION(LOCAL,"*.exe")
 
# ignore any directory named "images-backup" when uploading
ADDEXCLUSION(LOCAL,"images-backup\")
 
# ignore any directory named "testing" under the user desktop
ADDEXCLUSION(LOCAL,"C:\Users\Carlos\Desktop\test2\testing\")
 
# ignore any zip file under the user desktop\testing2 directory
ADDEXCLUSION(LOCAL,"C:\Users\Carlos\Desktop\test2\testing2\*.zip")
 
# This will return an error. If paths are used locally, they must 
# be absolute
ADDEXCLUSION(LOCAL,"Desktop\test2\testing2\*.zip")
# Connect to ftp.myftp.com
OPENHOST("ftp.myftp.com","myuser","mypassword")
 
# Download
# Do not download tmp files, ignore the directory cgi-bin
ADDEXCLUSION(REMOTE,"*.tmp")
ADDEXCLUSION(REMOTE,"cgi-bin/")
LOCALCHDIR("C:\dest_dir\")
GETFILE("*.*",SUBDIRS)
 
# Upload
# Do not upload the backup directory, ignore all
# jpg files in C:\mydir\photos
LOCALCHDIR("c:\mydir")
ADDEXCLUSION(LOCAL,"backup\")
ADDEXCLUSION(LOCAL,"*.jpg","C:\mydir\photos")
PUTFILE("*.*",SUBDIRS)
 
CLOSEHOST
OPENHOST("ftp.myserver.com","myuser","123456")
 
# Download all files and directories in /d/server
# apart from all files (not directories) in /d/server/temp
ADDEXCLUSION(DOWNLOAD,"*.*","/d/server/temp")
GETFILE("/d/server/*.*",SUBDIRS)
CLOSEHOST()

Return values:

OK: The command was successfully run.
18001: The path parameter cannot be empty.
18002: Wildcards are only allowed in the file name or directory name. Not in the path.
18003: The path parameter cannot be empty
18004: Wildcards are only allowed in the file name or directory name. Not in the path.
18005: If a local path is used it must be absolute. For example: C:\foo\bar\ or \foo\bar. Try also excluding only the file or directory name, without a path
18011: The filename or directory name cannot include a path. Indicate it using the additional optional parameter.
18012: The remote path cannot contain \\ . Use the / character as directory separator
18021: The filename or dirname cannot include a path. Indicate it using the additional optional parameter.
18022: The local path cannot contain / . Use the \\ character as directory separator
Any other error code corresponds to a Windows error code

Command History:

From ScriptFTP version 4.1 this command has changed its syntax. The third parameter (path) has been deprecated for simplicity.