xref: /curl/docs/cmdline-opts/remote-name.md (revision 2d3a51e3)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Long: remote-name
5Short: O
6Help: Write output to file named as remote file
7Category: important output
8Added: 4.0
9Multi: per-URL
10See-also:
11  - remote-name-all
12  - output-dir
13  - remote-header-name
14Example:
15  - -O https://example.com/filename
16  - -O https://example.com/filename -O https://example.com/file2
17---
18
19# `--remote-name`
20
21Write output to a local file named like the remote file we get. (Only the file
22part of the remote file is used, the path is cut off.)
23
24The file is saved in the current working directory. If you want the file saved
25in a different directory, make sure you change the current working directory
26before invoking curl with this option or use --output-dir.
27
28The remote filename to use for saving is extracted from the given URL, nothing
29else, and if it already exists it is overwritten. If you want the server to be
30able to choose the filename refer to --remote-header-name which can be used in
31addition to this option. If the server chooses a filename and that name
32already exists it is not overwritten.
33
34There is no URL decoding done on the filename. If it has %20 or other URL
35encoded parts of the name, they end up as-is as filename.
36
37You may use this option as many times as the number of URLs you have.
38