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

QNAP - Delete files of certain type recursively from command line


 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 2027
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
Topic Tags

Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).

Share: