Batch File – Cleaning the Desktop

This is a Windows Batch File, created to quickly move files from the desktop to specific folders. I grew tired of cleaning my desktop from those gathering files.

In this video, I cover what a batch (bat) file is and how you can utilize it to automate mundane tasks. I provide one I created, which I use every week, to automatically clean my desktop.

The purpose was to quickly clean off my desktop, as it tends to gather files. More importantly, it pushes those files to a specific folder, which is a specific hierarchy on my PC. This allows me to quickly find the files when I need them, without chasing them.

Below is the actual code I had created. You will notice I grouped similar file types together for ease of revision and reading.

REM -- Batch File created to push files to specific folders
REM -- Clean up Desktop
REM -- Created 11.27.19 via Matt Cole
REM -----------------------------------------------------------------

@echo on

REM -- Moves Excel Files

copy "C:\Users\colem\Desktop\*.xlsx"  "C:\MattCole\A_Files\Excel\*.xlsx" 
copy "C:\Users\colem\Desktop\*.xls"  "C:\MattCole\A_Files\Excel\*.xls" 
copy "C:\Users\colem\Desktop\*.csv"  "C:\MattCole\A_Files\Excel\*.csv" 

del *.xlsx
del *.xls
del *.csv


REM -- Moves Word Files

copy "C:\Users\colem\Desktop\*.docx"  "C:\MattCole\A_Files\Word\*.docx" 
copy "C:\Users\colem\Desktop\*.doc"  "C:\MattCole\A_Files\Word\*.doc" 
copy "C:\Users\colem\Desktop\*.rtf"  "C:\MattCole\A_Files\Word\*.rtf"

del *.rtf
del *.docx
del *.doc

REM -- Moves Pics

copy "C:\Users\colem\Desktop\*.png"  "C:\MattCole\A_Files\Pics\*.png" 
copy "C:\Users\colem\Desktop\*.bmp"  "C:\MattCole\A_Files\Pics\*.bmp" 
copy "C:\Users\colem\Desktop\*.jpg"  "C:\MattCole\A_Files\Pics\*.jpg" 
copy "C:\Users\colem\Desktop\*.JPEG"  "C:\MattCole\A_Files\Pics\*.JPEG" 
copy "C:\Users\colem\Desktop\*.JFIF"  "C:\MattCole\A_Files\Pics\*.JFIF" 
copy "C:\Users\colem\Desktop\*.webp"  "C:\MattCole\A_Files\Pics\*.webp" 
copy "C:\Users\colem\Desktop\*.PSD"  "C:\MattCole\A_Files\Pics\*.PSD" 
copy "C:\Users\colem\Desktop\*.gif"  "C:\MattCole\A_Files\Pics\*.gif" 

del *.jpg
del *.png
del *.bmp
del *.JPEG
del *.JFIF
del *.webp
del *.PSD
del *.gif

REM -- Moves Archived (Zip)

copy "C:\Users\colem\Desktop\*.zip"  "C:\MattCole\A_Files\Archived\*.zip" 
copy "C:\Users\colem\Desktop\*.rar"  "C:\MattCole\A_Files\Archived\*.rar" 
del *.zip
del *.rar

REM -- Moves ini files

copy "C:\Users\colem\Desktop\*.zip"  "C:\MattCole\A_Files\INI\*.ini" 
del *.ini


REM -- Moves PDF files

copy "C:\Users\colem\Desktop\*.pdf"  "C:\MattCole\A_Files\Adobe\*.pdf" 
del *.pdf

REM -- Moves Publisher files

copy "C:\Users\colem\Desktop\*.pub"  "C:\MattCole\A_Files\Publisher\*.pub" 
del *.pub

REM -- Moves Text files

copy "C:\Users\colem\Desktop\*.txt"  "C:\MattCole\A_Files\Text\*.txt" 
del *.txt

REM -- Moves MP3 and Video Files

copy "C:\Users\colem\Desktop\*.mp3"  "C:\MattCole\A_Files\Media\*.mp3" 
del *.mp3

copy "C:\Users\colem\Desktop\*.mp4"  "C:\MattCole\A_Files\Media\*.mp4" 
del *.mp4

copy "C:\Users\colem\Desktop\*.mov"  "C:\MattCole\A_Files\Media\*.mov" 
del *.mov

REM -- move Dat Files

copy "C:\Users\colem\Desktop\*.dat"  "C:\MattCole\A_Files\Dat\*.dat" 
del *.dat


REM -- Moves PowerPoint Files

copy "C:\Users\colem\Desktop\*.pptx"  "C:\MattCole\A_Files\PowerPoint\*.pptx" 
copy "C:\Users\colem\Desktop\*.ppt"  "C:\MattCole\A_Files\PowerPoint\*.ppt" 

del *.pptx
del *.ppt

REM -- Moves Visio Files

copy "C:\Users\colem\Desktop\*.vsdx"  "C:\MattCole\A_Files\Visio\*.vsdx" 
copy "C:\Users\colem\Desktop\*.vsd"  "C:\MattCole\A_Files\Visio\*.vsd" 

del *.vsdx
del *.vsd

REM -- Moves Project Plan Files

copy "C:\Users\colem\Desktop\*.mpp"  "C:\MattCole\A_Files\Project\*.mpp" 
del *.mpp

REM -- Moves Ebooks Files

copy "C:\Users\colem\Desktop\*.epub"  "C:\MattCole\A_Files\EBooks\*.epub" 
del *.epub


REM -- Moves Executible Files

copy "C:\Users\colem\Desktop\*.msi"  "C:\MattCole\A_Files\Executables\*.msi" 
del *.msi

copy "C:\Users\colem\Desktop\*.exe"  "C:\MattCole\A_Files\Executables\*.exe" 
del *.exe


REM -- Moves Teableau Files

copy "C:\Users\colem\Desktop\*.twbx"  "C:\MattCole\A_Files\Tableau\*.twbx" 

copy "C:\Users\colem\Desktop\*.twb"  "C:\MattCole\A_Files\Tableau\*.twb" 
del *.twbx
del *.twb


REM -- Moves Python Files

copy "C:\Users\colem\Desktop\*.py"  "C:\Users\colem\Desktop\PythonScript\*.py" 
del *.py

REM -- Moves Shortcut Files

copy "C:\Users\colem\Desktop\*.lnk"  "C:\Users\colem\Desktop\Shortcuts\*.lnk" 
del *.lnk


REM -- Moves PPK Files

copy "C:\Users\colem\Desktop\*.ppk"  "C:\MattCole\A_Files\PPK\*.ppk" 
del *.ppk

The REM statement is ‘Remark’ and anything followed by REM is ignored by the batch file. This is done primarily to create a comment to the author or others reviewing the code. I cannot say enough, to provide comments. If no comment is provided, you will come in later wondering why you wrote this code in a particular way. A good resource on Batch File commands can be found here.

The batch script is purposefully create to be simple. The same sequence occurs for each file on my desktop.

A) Copies file(s) to a dedicated folder.

B) Deletes file(s) from desktop.

Your not limited to only a specific main folder. Notice how I move my shortcuts to a shortcut folder on my desktop.

REM -- Moves Shortcut Files

copy "C:\Users\colem\Desktop\*.lnk"  "C:\Users\colem\Desktop\Shortcuts\*.lnk" 
del *.lnk

Maybe this will give you some additional ideas to help automate mundane tasks. You may also find my article on Python Programming History interesting.

Matt Cole has high regard for knowledge share. He has a desire to share critical thinking and information. With a Masters in Information Technology and a wide array of certifications, while not working full-time, he wishes to knowledge share through providing insight, information organization, and critical thinking skills.

#KnowledgeShare | Matt Cole | #infobyMattCole

Similar Posts

  • Education

    Education should be one of the core’s of our lives. By definition, education is the process of receiving or giving systematic instruction. This is done through schools or universities. However, this provision extends beyond these institutions. If one thinks about it, we receive education through entertainment, social interactions with others, and through personal research. One…

  • When we Pivot

    Pivot is the act of turning or a person or thing on which something depends; the central or crucial factor. I mentioned the need to pivot in another article I wrote. What does it mean to Pivot? When something isn’t working, you need to pivot (change) to something else. Basically, it is a switch to…

  • Defining the Problem

    Defining the problem is the first step in creating a successful project plan. Without a clear understanding of the problem, it’s impossible to develop a comprehensive plan that will address the root cause of the issue. In this article, we will discuss the importance of defining the problem and provide tips for effective problem definition….

  • Critical Thinking – Argument Analysis

    Mastering Critical Thinking: How Argument Analysis Can Improve Your Reasoning Skills In today’s world, being able to think critically is more important than ever. From political debates to everyday decision-making, the ability to evaluate arguments and make informed judgments is a crucial skill. One effective method for developing critical thinking skills is argument analysis, which…

  • Socratic Method – Preparing Your Questions

    Preparing your questions is a crucial step in effectively using the Socratic Method. The questions you ask will guide the conversation and shape the direction of the dialogue. To make the most of this powerful teaching tool, it’s important to take the time to develop a set of questions that are thoughtful, open-ended, and encourage…

  • Machine Learning

    Machine learning is a subfield of artificial intelligence (AI) that involves the development of algorithms and models that allow computers to learn from and make predictions based on data. The goal of machine learning is to create systems that can improve their performance on a specific task over time, without being explicitly programmed to do…