I want to upload some files in a local folder to a remote folder thanks to the command line's ftp client lftp.

What I want :

In my local computer, I do have :

me@local $ tree
├── index.html
└── css/

When I go to my FTP server, I want to have :

me@ftp_server $ tree
├── index.html
└── css/

What I want to do is to upload the local content of the my-site dir to the remote dev-site dir; but not the my-site dir itself. So I just want to upload files and remove this directory prefix name.

What I tried :

I tried this :

# On my local computer :
$ ls
$ lftp -u username,passwd ftp.foobar.cmo -e "mirror -R -p my-site/ dev-site/ ; quit"

Sadly, it uploads to local my-site dir into the remote dev-site, like :

# On my remote ftp server :
$ tree
└── my-site/
    ├── index.html
    └── css/

Workaround :

It works as excpected if I do :

# On my local computer :
$ cd my-site/
$ lftp -u username,passwd ftp.foobar.cmo -e "mirror -R -p ./ dev-site/ ; quit"

But I want to avoid this dirty cd.


Is there any way to remove a directory prefix while uploading files, in order to upload the content of a directory and not the directory itself ?

1 Answer 1


That about if you do the mirror without the last trailing slash at the destination ftp dir?

lftp -u user,password -e 'mirror -R -p /home/user/my-site dev-site ; quit' ftp.foo.cmo

Works here using lftp version 3.7.3:

adminnicolas@fw1:~$ lftp --version
LFTP | Version 3.7.3 | Copyright (c) 1996-2008 Alexander V. Lukyanov
  • Removing the trailing slash on the destination dir did the trick :) thanks @nwildner
    – PierreF
    Jan 13, 2017 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.