I am looking for command to delete all files with a specific extension in a given folder. Both, for windows and mac.
Thanks!
I am looking for command to delete all files with a specific extension in a given folder. Both, for windows and mac.
Thanks!
Using the find command will do the job efficiently.
Inside the folder,
find . -name "*.ext" -type f -delete
/!\ - Use this first to know what you are going to delete recursively.
find . -name "*.bak" -type f
Also, refer to the man find to know more about about it.
Before calling the del command you must also change the directory, for example a file bat could be like this
cd c:\MyFolderFullOfTmp
del *.tmp
This worked for me. I made a small function.
empty(){
cd $1
rm -rf *
cd -
}
empty PATH/TO/DIRECTORY
You can also use this function.
empty(){
rm -rf $1
mkdir $1
}
empty PATH/TO/DIRECTORY