Hi Cpp Programmers,
If you are tired of removing the *.o and *.exe files generated after compiling and running c/cpp files then you have come to right place.
This blog explains how to remove such files in Windows Platform. Later script for Linux version will also be added.
Suppose you have a parent directory called MyCppCodeRepo within which you might have children directory e.g. LinkedList, Trees, etc.
Here are the steps :
Explanation : del : deletes file supplied to it.
If you are tired of removing the *.o and *.exe files generated after compiling and running c/cpp files then you have come to right place.
This blog explains how to remove such files in Windows Platform. Later script for Linux version will also be added.
Suppose you have a parent directory called MyCppCodeRepo within which you might have children directory e.g. LinkedList, Trees, etc.
Here are the steps :
- Go to MyCppCodeRepo e.g. D:/myfile/MyCppCodeRepo/
- Create a file cleanUp.txt.
- Paste the following code : del /S *.o *.exe
- (OPTIONAL) If you want to see the logs (i.e which files are being deleted) add an additional line pause .
- Save and Exit.
- Rename the file to cleanUp.bat . This transforms the text file to a batch file.
- Now whenever you want to delete files of type *.o and *.exe in the current directory or any nested folder just double click it.
Explanation : del : deletes file supplied to it.
/S : looks for nested folder (recursively)
*.o and *.exe : * is for file name of any length. .o and .exe file types which we want to delete
You can copy and paste this small batch file in any directory and remove the desired file types. Suppose, after few months you start Java Programming then compiling Java files (*.java) generates java bytecodes which have *.class extension. If you want to delete these class files then just append *.class in line 3 of above steps.
Git provide .gitignore for this specific purpose - to exclude such binaries and other files generated at compile time. But writing your scripts to achieve these small tasks has its own satisfaction. Hope it helps you in keeping your work-space clean.
HAPPY PROGRAMMING.