I'm struggling to only retrieve subfolders from a remote windows share with the following directory structure using smbclient. Is there a way of issuing a command to only get folders? The command I have so far is:
smbclient //$host/$share -U"$USER%$PASSWORD" -c 'cd RootFolder; prompt; recurse; mget Test*\'
RootFolder/
Test001/
Revisions.txt
Test002/
Revisions.txt
Test003/
Revisions.txt
Test001=2012_12_05.log
Test001=2012_12_06.log
Test001=2012_12_07.log
Test001=2012_12_08.log
... more log files here
You could pipe the output of your command through grep
, looking for lines that end with /
.
smbclient ... | egrep '/$'
Instead, you could mount the remote windows file system and then use the find command to search for folders. The find command will search recursively for all directories only. This would be my recommended approach. Assuming you mount the windows filesystem as /mnt/win_host
...
find /mnt/win_host -type d