How do I transfer only the contents of a folder via ascp?



The ascp command line tool allows you to make transfers via a terminal/command prompt as well as in your scripts.

When transferring a folder to or from a remote directory, the default behavior is that the transferred folder is created if it does not exist on the destination.

Consider an example where you have a folder named my_Videos on your local machine with the following content:



Say you want to transfer the contents of my_Videos to a folder named received_Videos on a remote machine A new folder will be created on at the destination if it does not already exist. The command for transferring with ascp is the following:

ascp /path/to/my_Videos

This can become problematic if a folder received_Videos does exist on the remote machine prior to the transfer. In this case, running the above command will cause a folder named my_Videos to be created within the existing received_Videos:


To fix the issue so that only the content of my_Videos is transferred to received_Videos, you must use the --src-base option in your ascp command.


General use of --src-base

The syntax you use for an ascp command with --src-base is the following:

ascp --src-base=prefix [user@source_machine:]/path/to/folder [user@destination_machine:]/path/to/folder


The prefix value should be replaced with the path that you want stripped off the files being transferred. The --src-base option works for both files being uploaded to or downloaded from a remote source.


Example usage

The --src-base option allows you to strip off a portion of the paths of the source files being transferred.

Continuing with the example of the Description section, this means that we must strip the path of the files up to the folder my_Videos, so that only the files within my_Videos are transferred.

The command we would use to do this is the following:

 ascp --src-base=/path/to/my_Videos/ /path/to/my_Videos


In this way, for the file within my_Videos which has the full path of /path/to/my_Videos/, we will only be transferring to the destination.

Now we have the content that we want in the way we want it at the remote destination:


Have more questions? Submit a request


Article is closed for comments.
Powered by Zendesk