Command Line Interface Data Upload/Download
For more advanced users, a quick way to interact with Latch Data files is through the command line.
Setup
Install the Latch CLI:
The Latch CLI requires Python >=3.8 and < 3.11.
Next, authenticate your account. This can be done one of two ways:
If you’re on a computer where you’re logged into console.latch.bio, simply enter latch login
which will authenticate you through the browser that you’re logged into.
By default, LatchCLI references your personal workspace. To switch workspaces, use the command:
Copying Data
Upload files from local machine to Latch Data:
This uploads file.txt
and puts it into welcome/
on Latch.
Download files from Latch Data to local machine:
This downloads the contents of /welcome
on Latch and puts them into local_folder
on your local computer.
Copy files between two Latch Data paths in the same workspace:
This copies the contents of /dir1
on Latch and puts them into /dir2
on Latch.
Copy Latch Data files between two different workspace:
This copies the contents of /dir1
in workspace 123 and puts them into /dir2
in workspace 456.
Moving Data
You can also move data between two Latch directories.
For example, the following command will create file.txt
in dir2
and remove it from dir1
in your current workspace.
Syncing Data
The Latch CLI provides a simple way to sync data from a local directory to a Latch Data directory.
For example, the following command will update the contents of dir1
in Latch Data with the contents of local_folder
on your local computer.
If you add files to local_folder
and rerun the above command, the changes will be reflected in dir1
in Latch Data. The sync
command will only upload files when:
- The file does not exist in the remote directory.
- The last modified time of the file in the remote directory is older than the last modified time of the file in the local directory.
Note that, by default, the sync
command will not remove files from the remote directory if they are removed from local_folder
on your local computer. To allow files to be deleted from the remote directory, use the --delete
flag:
Other Commands
- List files in
dir1
: - Create directory
dir3
, creating parent directoriesdir1
anddir2
if they do not exist: - Recursively remove
dir2
in Latch Data:
Behavior
-
Using wildcards (*):
This copies all content within
local_directory
tolatch_folder
: -
Using trailing slashes:
This copies the directory itself and uploads it to
latch_folder
: -
Omitting the trailing slash:
This has the same behavior as
latch cp local_directory/ latch:///latch_folder
.
DEPRECATED
The following commands have been deprecated and will not be available for Latch SDK version >= 2.39.2.
To check which version of latch you are using, run latch --version
.
latch rm
- Uselatch rmr
insteadlatch mkdir
- Uselatch mkdirp
insteadlatch touch
- No longer supportedlatch open
- No longer supported
Was this page helpful?