I've a directory with many number of 0 byte files in it. I can't even see the files when I use the ls command. I'm using a small script to delete these files but sometimes that does not even delete these files. Here is the script:
i=100 while [ $i -le 999 ];do rm -f file${i}*; let i++; done
Is there any other way to do this more quickly?
The first part,-type d -empty -print -delete, will delete all the empty directories, and the second part, -type f -empty -print -delete, will delete all the empty files.
Before entering a command, right-click the taskbar and select Task Manager. Then right-click explorer.exe (Windows Explorer) in the Processes tab and select End task. Enter cd byte file path in the Command Prompt and press Enter. Replace '0-byte file path' with the actual folder path of the file.
Use find
combined with xargs
.
find . -name 'file*' -size 0 -print0 | xargs -0 rm
You avoid to start rm
for every file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With