remove all files ending with ~ in directory code example

Example 1: rm files with extension

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

Example 2: remove all files inside directory linux

# remove everything in a directory 
rm /path/to/dir/*
# remove all sub-directories and files
rm -r /path/to/dir/*

Example 3: Remove file extension from file within dir Ask Question

import os
os.path.splitext(current)[0]

Example 4: delete all files in a directory cmd

del /S C:\Path\to\directory\*