PowerShell: Working on Files

By Xah Lee. Date: . Last updated: .

Delete a File

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

Rename or Move File

# move all jpg files to parent dir
Move-Item *.jpg ../
# rename a file
Move-Item screenshot_2023-12-28_225857.png house.png

Copy File

# copy a file in current dir to parent dir
cp my_photo.jpg ../
# copy all file to a f drive
cp ~/Pictures/Screenshots/* f:/backup/

PowerShell, Working on Files