SMB Deleting Files in Bulk

photokid86

Cadet
Joined
Jan 3, 2022
Messages
5
I am having a difficult time deleting on my zfs nas drive using an app to search/index. Mac users are SMB shared to this volume and it's taking forever to search for files based on modified date, type, etc. In finder its almost useless to wait and the smart search options dont work.

I am using an app HoudahSpot to find them, but it seems to have an issue deleting files. In addition I was able to find a hidden ".recycle" folder but nothing was going there.

Please help if oyu have a solution to quickly find files and remove from the storage.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
are you insisting on using a GUI, or would ssh be OK?

find /starting/path -maxdepth 4 -type f -name "*.doc" -print0 | xargs -0 rm

You could remove the maxdepth or adjust it if that makes sense.
 

photokid86

Cadet
Joined
Jan 3, 2022
Messages
5
Thank you for replying and offering support. I am a rookie when it comes to ssh but willing to learn!

In the command line you sent, would it possible to search the following criteria:

File Extension: ".cr2" , ".cr3" , ".nef , ".arw" , ".dng" , ".raf"
Modified before: 30 days in the past
Exclude directories: /Volumes/production/D/Dusty_New_4514

Then this would automatically delete them or show me a list of files? If it shows a list of files can I bulk delete them simply from the command module?

Using a GUI makes it more user friendly and gets me a list of files based on the criteria above, I then move to a single folder and delete in Finder. This is my current and clunky workflow.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Then this would automatically delete them or show me a list of files? If it shows a list of files can I bulk delete them simply from the command module?
The example I gave uses the find command to send a list of files to delete to the rm (remove) command. (this is the part at the end... -print0 | xargs -0 rm

If you take off the last part (-print0 | xargs -0 rm), it will only list the files that would have been deleted.

In the command line you sent, would it possible to search the following criteria:

File Extension: ".cr2" , ".cr3" , ".nef , ".arw" , ".dng" , ".raf"
Modified before: 30 days in the past
Exclude directories: /Volumes/production/D/Dusty_New_4514
The command for that would look like this (to list the files):

find . -mtime +30 -type f \( -name "*.cr2" -o -name "*.cr3" -o -name "*.nef" -o -name "*.arw" -o -name "*.dng" -o -name "*.raf" \) -not -path "./production/D/Dusty_New_4514/*"

Note that I'm assuming you're on the TrueNAS server (ssh), so I'll assume you did a CD to wherever the share is.

If you were happy with the list and want to delete the files...

find . -mtime +30 -type f \( -name "*.cr2" -o -name "*.cr3" -o -name "*.nef" -o -name "*.arw" -o -name "*.dng" -o -name "*.raf" \) -not -path "./production/D/Dusty_New_4514/*" -print0 | xargs -0 rm
 
Last edited:

photokid86

Cadet
Joined
Jan 3, 2022
Messages
5
I am currently using FreeNAS-11.3-U5 and attempted this find command in "shell".

I didn't see any files populate after hitting "return".

Maybe I missed something with CD (change directory).
 

Attachments

  • Screen Shot 2022-01-12 at 3.23.17 PM.png
    Screen Shot 2022-01-12 at 3.23.17 PM.png
    39.2 KB · Views: 130

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
the . after find indicates to start from the present working directory... (you can see what that is by typing pwd.

If that's not where you meant to start, you can Change Directory (cd) to another one... cd /mnt/tank/dataset/smbshare (obviously substituting a path that exists on your server)
 

photokid86

Cadet
Joined
Jan 3, 2022
Messages
5
I ran the command above and the storage seems to be self-deleting files. Daily I notice the capacity increase as we have new files coming into the system. Is this normal?

Also, the storage seems to be running slower in terms of transfer - is there a way to view this command in the logs to see if its running a process in the background?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Do you have Snapshots?

Deleted files are still taking space in Snapshots while they exist.

htop gives a real time view.

ps -aux shows a static full list.
 

photokid86

Cadet
Joined
Jan 3, 2022
Messages
5
Yes I do have Snapshots for a rolling 30 days, thats an interesting point.

So likely these were deleted previously, then kept in snapshot until snapshot deleted?
 
Top