18

When I try to fetch a directory with get "Path To\Directory\", I get the following error:

NT_STATUS_FILE_IS_A_DIRECTORY opening remote file Path To\Directory

How do I recursively download this directory?

(Using smbclient v3.6.23. The server is a computer running Windows 7 Home Edition.)

  • smbclient uses the same type of semantics that server clients like FTP and HTTP do, where each get or put targets one file. you can write scripts to perform retrievals by directory, or you can use the mget/mput commands to specify a mask or wildcard to retrieve multiple files, as shown in my answer. it may be that smbclient isn't quite the right tool for your purposes. – Frank Thomas Dec 25 '14 at 4:23
43

per the smbclient manpage, you need to use the mget command, with a mask and recursion and prompt set. Then cd to the directory you want to get recursively

    smbclient '\\server\share'
    mask ""
    recurse ON
    prompt OFF
    cd 'path\to\remote\dir'
    lcd '~/path/to/download/to/'
    mget *

or, all on one line,

smbclient '\\server\share' -N -c 'prompt OFF;recurse ON;cd 'path\to\directory\';lcd '~/path/to/download/to/';mget *'

if you need to authenticate to the server drop -N and use the Password setting on the connect command.

http://technotize.blogspot.com/2011/12/copy-folder-with-ubuntu-smb-client.html

  • 1
    Also, I think you've got your quotes a bit confused in the one-liner. My smbclient only seems to like dealing with directories in "double quotes". – c24w Jun 7 '17 at 14:32
  • Just copied and replaced folders but it didnt work - ends with trailing > – Wax Cage Aug 7 '17 at 21:40
  • For people really want to copy without problems follow this article: indradjy.wordpress.com/2010/04/14/… (helped me) – Wax Cage Aug 7 '17 at 21:46

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.