Delete files from command line using smb:// URL

8,429

Solution 1

Linux or Windows or whatever?

Linux: smbclient … -c "rm $filename" – but be aware of filenames with unusual characters: you may have to escape or quote $filename.

Alternate solution: simply mount the filesystem(s), and access the files with the usual command-line tools.

Solution 2

In addition to Matthias Urlichs answer,

smbclient ... -c "del $filename"

Per smbclient documentation.

Share:
8,429

Related videos on Youtube

devmiles.com
Author by

devmiles.com

Updated on September 18, 2022

Comments

  • devmiles.com
    devmiles.com almost 2 years

    I have a file with a list of smb:// URLs, like this one:

    smb://my_samba_host/data/need_to_be_removed.tgz
    smb://my_samba_another/data/need_to_be_removed2.tgz
    

    I need a command line (something using xargs probably) that would allow me to remove all those files and I'm struggling to come up with one.