PowerShell: Delete Files

By Xah Lee. Date: .

Delete a File

# delete a file in current dir
rm .\photo.jpg
# delete a file by path
rm "~/travel photo.jpg"

Delete File by Wildcard Pattern

delete by Wildcard pattern.

# delete macOS folder preference file
dir -recurse -Force -filter .DS_Store | rm -Force
# delete emacs backup. file name ending in ~
dir -recurse -file -filter *~ | rm

〔see List File by File Name Pattern

PowerShell, Working on Files