I developed a mini project using C which can be used to sort files in a cluttered directory to different folders. The program deals with the main types of files we commonly deal with like pictures, videos, music & documents. The program lets you name the folders where you want to move different types of files. The program uses Windows commands so it is only compatible for Windows operating system. Let's call it Sort 2 Folder.

Working

The C program does not need any external header files to run.

The header files needed are stdio.h, stdlib.h and string.h .

Character 2D array a[4][20] stores the name of the folders, there are a total of 4 folders to be created and the folder names can have up to 20 characters.

The creation of folder and moving of files are done by system() in C

For creation folders windows command mkdir "<file name>" is used in system().

sprintf(buffer,"mkdir \"%s\"",a[i]);

system(buffer) ;





In the above code buffer is a character array which is predefined sprintf stores or prints the system command

"mkdir \"%s\"",a[i] into buffer array and later called system() with buffer as an argument.

The same process is happening when sorting and moving files to these folders, the changes are, we use the system command to move files by their extension.

sprintf(buffer, "move *.png \"%s\"", a[i]);

system(buffer);