Recently, I felt overly annoyed by my messy download folder on my personal computer. There were too many files, and it was in a total mess. I thought to write a simple bot to address this problem.
Solution is a Bot that loops the download,desktop or any other folder and determines the file type for each and every file. Subsequently, it creates a folder for that file type. All files with the same file type will be transferred to this folder and or Organise by Date.
We use .Net Core to make it cross platform. but same code work well for .Net Framework ,.Net Standard and on Xamarin so it work on every popular device today.
let start it by creation new project and initialize git.
dotnet new console -o “FileOrganizer”
git add *.*
.Net provide FileSystemWatcher to watch for changes in a specified directory. You can watch for changes in files and sub directories of the specified directory. You can create a component to watch files on a local computer, a network drive, or a remote computer.
The FileSystemWatcher does not raise events for CDs and DVDs, because time stamps and properties cannot change. Remote computers must have one of the required platforms installed for the component to function properly.
we make directory in Organised path such as File Type , year , Mount and then date.
it work fine but when it overwrite file with same name, so we add check.
when file is other press it throw exception to overcome this problem we try to reach file until file is open to move.
so we have to add configuration file to add or update information with out making changes in code and generate logs of files with time.