Examples of ascp exclude patterns



When using ascp on the command line, you can specify patterns to exclude certain files or directories from being transferred. The following examples assume you are familiar with basic ascp commands (refer to your transfer server manual for more details).


The general syntax of an ascp command with exclude patterns is the following:

# ascp -E “pattern_1” -E “pattern_2” source_directory transfer_user@remote_host.com:/
# ascp -E “pattern_1” -E “pattern_2” transfer_user@remote_host.com/source_directory local_directory


Exclude patterns for ascp support two symbols for pattern matching, including:

  • * to match zero or more characters
  • ? to match a single character

You can define up to 16 exclude patterns in a single command.



The following examples will show only the exclude option and pattern and the source directory to be transferred, from the local to remote host.

1. Transfer all files except those of a certain type

For example, if we want to transfer the folder Final_Photos but exclude all GIF files, you can add the following exclude pattern:

ascp -E “*.gif” Final_Photos ...


If we want to also exclude any files with the word “edit” in them, we can add the following exclude pattern:

ascp -E “*.gif” -E “*edit*” Final_Photos ...


2. Exclude specific directory/files

In some cases you may want to exclude a specific directory or files within a specific directory. You can do so by defining the absolute path.

Say you you want to exclude the text files from the scripts sub-directory of your home folder, but you still want to transfer text files located anywhere else. To do this you would use the following:

ascp -E “/home/janedoe/scripts/*.txt” /home/jane/doe ...


If you decide you want to exclude other text files located under the scripts directory as well, you can define additional patterns for the sub-directory level you want to exclude text files from:

ascp -E “/home/janedoe/scripts/*.txt” -E “/home/janedoe/scripts/*/*.txt” “/home/janedoe/scripts/*/*/*.txt” 


3. Exclude any sub-directory

At times you may need to exclude all sub-directories at a certain level. In this case you will need to exclude everything on the level right below it. Note that this means all the sub-directories on your target level will still be transferred, but they will be empty.

As an example, if you want to transfer all the files in Music_Clips but exclude all the sub-directories in it, you could do something like the following:

ascp -E "/Music_Clips/*/*" /Music_Clips
Powered by Zendesk