Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



QNAP - Delete files...
 
Share:
Notifications
Clear all

[Solved] QNAP - Delete files of certain type recursively from command line

1 Posts
1 Users
0 Reactions
3,946 Views
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2791
Topic starter  

I just had to cleanup a lot of files, and wanted to use the Linux "find" command for that.
As an example, to remove all JPG files from all directories in a given directory. Under Linux that could be done as such:

find . -name "*.jpg" -type f -delete

This will find all files ending with .jpg and delete them.
If you'd want to do a test run first without deleting the files, you could try the following to show you the full list:

find . -name "*.pt.srt" -type f

However .... your beloved QNAP uses the BusyBox find version, which does NOT support this "delete" option.

The proper version is supposed to come with OptWare, but on my QNAP it was nowhere to be found (look in "/opt/bin" to see if "find" and "findutils-find" can be found).

In case yours (like mine) is missing that one, do the following to install the correct find version:

ipkg update
ipkg install findutils

In the directory "/opt/bin" you'll now find the following new files:

/opt/bin/find
/opt/bin/findutils-find
/opt/bin/findutils-xargs

To use this version of find, the statement changes a little bit:

/opt/bin/find . -name "*.jpg" -type f -delete

   
ReplyQuote
Share: