3

I'm trying to delete files that end with "_n.png" or "_s.png". How do i do that?

3

Assuming there are many files that meet the specifications and may be in more then one location, I'd use the find command from Terminal, as shown in the following simple example:

$ find . -type f \( -iname '*_n.png' -o -iname '*_s.png' \)
./Pictures/foobar_n.png
./Pictures/Temp/barfoo_s.png
$ 

In the output of the find command above, we see it found the two sample files I created for testing. As I'm sure those are the files I want to delete I run the same command but with adding -delete to it, as shown below:

find . -type f \( -iname '*_n.png' -o -iname '*_s.png' \) -delete

If all the files are in the same directory or you just want to delete these files in a specific directory, use:

cd /path/to/directory
rm *_[ns].png

NOTE: Using find with the -delete option or rm immediately deletes the files found, they are not placed in the Trash and they are generally not recoverable!

So do not use this commands unless you're okay with the note above!


If you prefer to use a GUI method, there is a nice freeware app by DEVONtechnologies, LLC called EasyFind and is available in the App Store or the developers website.

As you can see in the image below, EasyFind found the sample files created for testing. Simply select the ones you want to delete and then click Delete on its Toolbar to place the selected items in the Trash.

EasyFind Search Results

The nice feature of EasyFind is , with its various setting and controls, it's capable of making some searches that are not possible to perform in Finder while providing the user with a GUI interface, and without having to use Terminal.

Note that I'm not affiliated with the developer of EasyFind, just a happy user of the product.

3
  1. Open the folder containing the files in Finder
  2. Press Command-F
  3. Change the first pulldown to "Name"
  4. Change the second pulldown to "ends with"
  5. Enter your search criteria, e.g. "_s.png"
  6. Drag the files from the search result to the Trash

Finder search name ends with

Option-clicking the "+" icon (at the end of the filter row) changes the icon to "…" which allows you to combine search operations, e.g. find files ending with both search terms in one search operation.

Finder search combine terms

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .