Linux – bash how to remove all files with multiple extensions except one directory

bash how to remove all files with multiple extensions except one directory… here is a solution to the problem.

bash how to remove all files with multiple extensions except one directory

I have this snippet

Find .\( -iname\*.ini -o –

iname\*.properties -o -iname\*.xml\) -type f -delete

This deletes everything in all subfolders that contain these extensions, which is exactly what I want.

The only change I want to make is now I want it to exclude a directory named “Resources/”. I want it to remove all noticed expansion files in all subfolders except the Resources directory.

But I’m not sure how to do it.

Thanks for any help

Solution

The following command should exclude the resource directory

find . \( -iname \*.ini -o -iname \*.properties -o -iname \*.xml \) -type f -not -path "./resources/*" -delete

Related Problems and Solutions