Category filter
Scripts to delete Files and Folders on Windows 10
When the number of files/folders in an organization increases, the administrators might need to delete outdated files. With more and more machines getting remote, admins find this task increasingly difficult. Hexnode lets admins handle this action via scripts on Windows devices.
To delete a file
Batch Script
1 |
del “filename_with_location.ext” |
E.g., To delete the file test.txt in the Desktop of the user Deborah,
del “C:\Users\Deborah\Desktop\test.txt”
Powershell Script
1 |
remove-item “filename.ext” |
E.g., To delete the file test.txt in the Desktop of the user Deborah,
remove-item “C:\Users\Deborah\Desktop\test.txt”
To delete a folder
Batch Script
1 |
rmdir /Q/S “foldername_with_path” |
E.g., To delete a folder test in the Desktop of the user Deborah,
rmdir /Q/S “C:\Users\Deborah\Desktop\test”
Powershell Script
1 |
remove-item “foldername_with_path” -recurse |
E.g., To delete a folder test in the Desktop of the user Deborah,
remove-item “C:\Users\Deborah\Desktop\test” -recurse