Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

Is there an easy way to remove all thumbs.db from mounts?

Status
Not open for further replies.

HHawk

Member
Joined
Jun 8, 2011
Messages
176
I have an annoying problem.

Apparently Windows thought it was necessary to play in every directory I have visited on my Freenas files called "thumbs.db". Just now I disabled it within Windows, however the "damage" has already been done unfortunately.

Now Windows has created almost in every directory a filled called "thumbs.db". Which limits me to delete a directory when browsing through my FreeNAS with another PC on the network / internet.

Is there an easy way through SSH to delete all "thumbs.db" from alle directory within my mount?
If so, can someone please explain. I am a complete Unix newbie and I do not want to damage and / or delete the wrong files if I start experimenting.

Sorry if this is a really stupid question, but I already searched Google and it came up with 2 hits, however those didn't work for me.
 

HHawk

Member
Joined
Jun 8, 2011
Messages
176
Probably you misunderstood, but I need to remove the files called "thumbs.db" from my FreeNAS server, not from my Windows machines (which is easy).
And furthermore, as I explained, I cannot remove the thumbs.db from Windows through LAN. I need to do this through SSH instead (that's why I asked).
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526

HHawk

Member
Joined
Jun 8, 2011
Messages
176
I already disabled it, also mentioned in the first post, however the files (thumbs.db) are now on the server (everywhere).
That's why I am asking how to remove those files from SSH.

There must be a command you can run in Unix / FreeNAS to remove files from all directories called "thumbs.db", right?
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
This worked for me in a test directory. It removed all of my test files in subdirectories. Use at your own risk. Note that the last / in/your/directory/here/ is important.

find /your/directory/here/ -name "thumbs.db" -exec rm {} \;
 

HHawk

Member
Joined
Jun 8, 2011
Messages
176
Thank you, I will give it a go when I am back home. Hopefully this rids my FreeNAS server from those stupid files Windows created. :(
 

titan_rw

Neophyte Sage
Joined
Sep 1, 2012
Messages
591
Telling the clients not to create them is the best option.

However, you can always tell samba to not allow creation of them on the server. Samba option "veto files" or similar. Check the samba docs for more.
 

HHawk

Member
Joined
Jun 8, 2011
Messages
176
I did read something about the "veto files" syntax, but wasn't sure.
But thank you! I will certainly look into this.

Your reply was highly appreciated.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Telling the clients not to create them is the best option.

However, you can always tell samba to not allow creation of them on the server. Samba option "veto files" or similar. Check the samba docs for more.
You have to be careful with what files you veto. I believe that they way it works internally is Samba dishes out the folder with correct permissions(presumably writeable) but when you try to create the file thumbs.db Samba replies with what is equivalent to "read-only" for that file. In some instances this confusion can cause programs(in this case explorer.exe I believe) may crash because it thinks it should have write permissions, but then gets told it doesn't. I remember reading some thread from 2011 where there was some discussion about removing the "veto" option from Samba because of how many problems it can cause.
 

HHawk

Member
Joined
Jun 8, 2011
Messages
176
Ah okay, I will skip that than and will just find and delete the thumbs.db files as you told me with the correct command instead.
If I did everything correctly, Windows-wise, it shouldn't create thumbs.db anymore anyways.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
You could create a cronjob that runs nightly to cleanup any thumbs.db that is created. I'm not really sure why you are obsessing over the thumbs file. They're pretty harmless, don't take up alot of space or anything. I hate them myself, but they aren't even worth my time to deal with them.
 

HHawk

Member
Joined
Jun 8, 2011
Messages
176
Well because, also mentioned in my first post, I cannot remove directories from other PC's, which contain those thumbs.db files to begin with.
So I am not "obsessed" with thumbs.db and I find that kinda offensive.
 

HHawk

Member
Joined
Jun 8, 2011
Messages
176
Excellent! I ran the command last night and it worked great.
I only had to change thumbs.db to Thumbs.db. I forgot FreeNAS / Unix is case-sensitve.

Thank you for the help!
 

emk2203

Senior Member
Joined
Nov 11, 2012
Messages
496
The easiest would be
Code:
find . -iname 'thumbs.db' -delete
in the directory which you want to scan.
Leave off the -delete for a test run.
 

MaIakai

Member
Joined
Jan 24, 2013
Messages
25
Code:
find . -name 'Thumbs.db*' -print0 | xargs -0 rm -r
find . -name 'desktop.ini*' -print0 | xargs -0 rm -r

is what I use.
 

emk2203

Senior Member
Joined
Nov 11, 2012
Messages
496
Why do you pipe into xargs when find can delete with the -d option as well? Just curious.
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,357
xargs can execute in parallel and find is serial. xargs -p 7 for example will run 7 tasks at a time.
 

emk2203

Senior Member
Joined
Nov 11, 2012
Messages
496
xargs can execute in parallel and find is serial. xargs -p 7 for example will run 7 tasks at a time.
If you pipe from find, it will still be the bottleneck, so nothing won.

In the end, it boils down to preference.
 
Status
Not open for further replies.
Top