

Replacing the process is one of the most known implementations of exec in the shell script. Use the exec command to replace process in shell script Seems complex? Let me give you some examples of using the exec command in shell scripts: It replaces the shell process with the specified command. But exec runs the Linux commands without starting a new process. Wait! Don't shell scripts execute Linux commands already? They do.

Technet documentation for del command can be found here. This is scheduled to run at night, but sometimes I need to run it during the day so the quicker the better. This is a regular task for me, so I usually move the stuff I need to delete to C:\stufftodelete and have those del+rmdir commands in a deletestuff.bat batch file. This is nearly three times faster than a single rmdir, based on time tests with a Windows XP encrypted disk, deleting ~30GB/1,000,000 files/15,000 folders: rmdir takes ~2.5 hours, del+rmdir takes ~53 minutes. A second pass then cleans up the remaining directory structure: del /f/s/q foldername > nul The best I've found is a two line batch file with a first pass to delete files and outputs to nul to avoid the overhead of writing to screen for every singe file. del /f/s/q foldername is good too, but it leaves behind the directory structure.

Next best is to use rmdir /s/q foldername from the command line. Next worst is shift+delete with Windows Explorer: it wastes loads of time checking the contents before starting deleting anything. The worst way is to send to Recycle Bin: you still need to delete them.
