Clean Up a Sloppy Desktop in 3 Seconds With This Script.

Posted on | Saturday, September 4, 2010 | 1 Comment

Ever seen a desktop that looks like this?



This sloppy madness is all too common. And once it gets this bad, trying to find even a single file on the desktop becomes a problem. Not only is it hard to locate the files you can see, but new files you save to your desktop probably won't show up there, as you've run out of screen real-estate.

Now, normally, if you run into a desktop like this, and a user who complains about it, you would just suggest that they create a few folders and spend some time moving their files, one by one, into them. And this works fine, except for the fact that it is severely time consuming. Not only that, but if a user has let the desktop get this cluttered, it is likely they will have it cluttered again soon.

To deal with the clutter, and the time consuming nature of desktop cleanup, I wrote a script called D-Sweeper that will clean up even the most unreasonably cluttered desktop in only a few seconds.

Usage:

To use this script, you need to do the following things:
  • Copy the following commands into a text file and name it D-Sweeper.bat 

Code:
@echo on
cd "%USERPROFILE%\Desktop"

::Check to see if the directories already exist
:DOCUMENTSFOLDER
If exist "%USERPROFILE%\Desktop\D-Sweeper\Documents" Goto AUDIOFOLDER
mkdir "%USERPROFILE%\Desktop\D-Sweeper\Documents"
:AUDIOFOLDER
If exist "%USERPROFILE%\Desktop\D-Sweeper\Audio" Goto VIDEOFOLDER
mkdir "%USERPROFILE%\Desktop\D-Sweeper\Audio"
:VIDEOFOLDER
If exist "%USERPROFILE%\Desktop\D-Sweeper\Video" Goto PROGRAMSFOLDER
mkdir "%USERPROFILE%\Desktop\D-Sweeper\Video"
:PROGRAMSFOLDER
If exist "%USERPROFILE%\Desktop\D-Sweeper\Programs" Goto PICTURESFOLDER
mkdir "%USERPROFILE%\Desktop\D-Sweeper\Programs"
:PICTURESFOLDER
If exist "%USERPROFILE%\Desktop\D-Sweeper\Pictures" Goto ARCHIVESFOLDER
mkdir "%USERPROFILE%\Desktop\D-Sweeper\Pictures"
:ARCHIVESFOLDER
If exist "%USERPROFILE%\Desktop\D-Sweeper\ARCHIVES" Goto DOCUMENTS
mkdir "%USERPROFILE%\Desktop\D-Sweeper\Archives"


:DOCUMENTS

move /-y "%USERPROFILE%\DESKTOP"\*.doc "%USERPROFILE%\Desktop\D-Sweeper\Documents"
move /-y "%USERPROFILE%\DESKTOP"\*.pdf "%USERPROFILE%\Desktop\D-Sweeper\Documents"
move /-y "%USERPROFILE%\DESKTOP"\*.txt "%USERPROFILE%\Desktop\D-Sweeper\Documents"
move /-y "%USERPROFILE%\DESKTOP"\*.rtf "%USERPROFILE%\Desktop\D-Sweeper\Documents"
move /-y "%USERPROFILE%\DESKTOP"\*.xls "%USERPROFILE%\Desktop\D-Sweeper\Documents"
move /-y "%USERPROFILE%\DESKTOP"\*.ppt "%USERPROFILE%\Desktop\D-Sweeper\Documents"
move /-y "%USERPROFILE%\DESKTOP"\*.docx "%USERPROFILE%\Desktop\D-Sweeper\Documents"

:AUDIO

move /-y "%USERPROFILE%\DESKTOP"\*.wav "%USERPROFILE%\Desktop\D-Sweeper\Audio"
move /-y "%USERPROFILE%\DESKTOP"\*.mp3 "%USERPROFILE%\Desktop\D-Sweeper\Audio"
move /-y "%USERPROFILE%\DESKTOP"\*.aiff "%USERPROFILE%\Desktop\D-Sweeper\Audio"
move /-y "%USERPROFILE%\DESKTOP"\*.aac "%USERPROFILE%\Desktop\D-Sweeper\Audio"

:VIDEO

move /-y "%USERPROFILE%\DESKTOP"\*.avi "%USERPROFILE%\Desktop\D-Sweeper\Video"
move /-y "%USERPROFILE%\DESKTOP"\*.dvx "%USERPROFILE%\Desktop\D-Sweeper\Video"
move /-y "%USERPROFILE%\DESKTOP"\*.mov "%USERPROFILE%\Desktop\D-Sweeper\Video"
move /-y "%USERPROFILE%\DESKTOP"\*.mpg "%USERPROFILE%\Desktop\D-Sweeper\Video"
move /-y "%USERPROFILE%\DESKTOP"\*.rm "%USERPROFILE%\Desktop\D-Sweeper\Video"
move /-y "%USERPROFILE%\DESKTOP"\*.swf "%USERPROFILE%\Desktop\D-Sweeper\Video"
move /-y "%USERPROFILE%\DESKTOP"\*.wmv "%USERPROFILE%\Desktop\D-Sweeper\Video"
move /-y "%USERPROFILE%\DESKTOP"\*.xvid "%USERPROFILE%\Desktop\D-Sweeper\Video"

:PROGRAMS

move /-y "%USERPROFILE%\DESKTOP"\*.exe "%USERPROFILE%\Desktop\D-Sweeper\Programs"
move /-y "%USERPROFILE%\DESKTOP"\*.bat "%USERPROFILE%\Desktop\D-Sweeper\Programs"
move /-y "%USERPROFILE%\DESKTOP"\*.cmd "%USERPROFILE%\Desktop\D-Sweeper\Programs"

:PICTURES

move /-y "%USERPROFILE%\DESKTOP"\*.jpg "%USERPROFILE%\Desktop\D-Sweeper\Pictures"
move /-y "%USERPROFILE%\DESKTOP"\*.bmp "%USERPROFILE%\Desktop\D-Sweeper\Pictures"
move /-y "%USERPROFILE%\DESKTOP"\*.png "%USERPROFILE%\Desktop\D-Sweeper\Pictures"

:ARCHIVES

move /-y "%USERPROFILE%\DESKTOP"\*.zip "%USERPROFILE%\Desktop\D-Sweeper\Archives"
move /-y "%USERPROFILE%\DESKTOP"\*.rar "%USERPROFILE%\Desktop\D-Sweeper\Archives"
move /-y "%USERPROFILE%\DESKTOP"\*.7z "%USERPROFILE%\Desktop\D-Sweeper\Archives"

REM Please take note: Below is a PGP encrypted message. Only the original author can decrypt this message, as only
REM the original author has access to the secret key that is needed to decrypt it. Also, unless this PGP message
REM is included in this file, the hash values of this file (MD5, SHA-1, and Whirlpool) will not match up with 
REM the authentic hash values that are posted along with this desktop clean up script. Therefore, authenticity and original ownsership are guranteed.

REM -----BEGIN PGP MESSAGE-----
REM Version: GnuPG v2.0.14 (MingW32)

REM hQEMAyR0JCQV5M/xAQf9FD2JyGsyzTHefCeqOouEehTLhyWw+CpdxBBkHj3Pyi/c
REM dmQ799qkG4UNiRFTDwRBHygAhHFyJ9o2msUJmxYLqeNiHWnVEBqReUCVcXCN7la5
REM aAwVavKugr3zgtTXQCeobQt5S6vZmEWv9PM5NMb3Mwhw8puRUvc67OWRhZvxrudy
REM T/ENasU6Ruimxs9tuRINJsxJ+mYJYK+QxI0fgyr7F0q9ORvgo4xktFNdaX5iz8pd
REM aHrpF5LRlLvLVXZrgvGpN8l+WmI61TOPpej7Tf9W9ksQlEsOGihNDAVN0bkMEkv5
REM LOw3ySW1ia7tyXjdFFxGkaUepcJFSMrR3XuXjwMxmtLAmQHxKyxFiV7Hbk+e55dh
REM k4/a1Nnr9xUgIXxOAAy9n2plMa50U36KxgqjpsmU54Qu2wWJzRlQdLLEsjANs/50
REM 7UpPUd0nYaPzgak7YLE2jCTc54IBEd70b0v7OguYDNNR6MLKHfRt+kE0oNhm9cLM
REM IgqU6VQxrKro1W2XvElC3ONGPOcSh+BmKENE+AGgutzxwhfwr2mPguqAnyENLFhY
REM 1Q2HJ9uBEOfGlZyI5VcOOFYwR2wIPmvrCh80Kj71K+W+nT4txrAgBu3fg/AhIlo2
REM 4K1/wRl/HukQ5QdMFONNylVIW71NmQz2xt8kbp7mgGcptM64f12maQ4sMRFyWxGu
REM ExdHXzTXtova9RjPcMpAM5c+CDoUE4803ycLW94/lGnKn/3z13SqxCFW0VX9eYoO
REM Rtyi9GSXZIpVCeJrmsYvHzSp7wicnz1aU1/aYC1duskwcUJGrL+sM153gQ==
REM =QZRN
REM -----END PGP MESSAGE-----
  • Double click the D-Sweeper.bat file to start cleaning.
How It Works:

Upon running the D-Sweeper.bat file, the program navigates to the desktop and then runs through a series of checks to see if the D-Sweeper folder and sub-category folders exist ( If exist "%USERPROFILE%\Desktop\D-Sweeper\Documents" Goto AUDIOFOLDER ). If it finds that a certain sub folder does exist, it skips creating that folder and then moves on to the next one. If it cannot find a D-Sweeper folder or an associated sub-category folder, then it will create it using the make directory command ( mkdir "%USERPROFILE%\Desktop\D-Sweeper\Documents" ). When finished, D-Sweeper will have either verified or created 6 sub directories inside of the D-Sweeper folder--documents, audio, video, programs, pictures, and archives. 
Quick Tip: Organize a Sloppy Desktop in Seconds with D-Sweeper 1.0-folders.jpg

Once the folders have been created, D-Sweeper will scan through the files on your desktop, looking for various types of files, such as .doc files, .pdf files, .mp3 files, etc. As it finds each type of file, it will place the file inside of the appropriate sub folder in the D-Sweeper directory.  

It does this, and very quickly, by simply using the move command and the /-y switch for safety. The /-y switch forces the move command to prompt the user for permission to overwrite a file, if it ever finds a file with the same name in the destination directory. Also, D-Sweeper only organizes files, not folders, so it will not affect any of the current folders on your desktop.

When your desktop starts to get cluttered again, simply run D-Sweeper again to clean it back up. You can use it as a regular desktop cleaner, or just as a means to quickly move and organize your files.

Technical Notes & File Type Request:
  1. D-Sweeper has been designed to only scan through files on the desktop, and it does not recurse through subdirectories. Reason being, of course, that its purpose is to clear up screen real-estate and to organize desktop files into neat folders. You could, of course, modify this file to recurse sub directories on your entire HDD, but you probably wouldn't want to :)
  2. D-Sweeper is set up to search for the most common file types at the moment. But it's easy enough to modify it for all your favorite file type extensions. For instance, if you wanted to have the script search for the .nre file extension (not a real file extension) and place it in the Video folder, Then you would simply add the following line under the video label of the script: 

    move /-y "%USERPROFILE%\DESKTOP"\*.nre "%USERPROFILE%\Desktop\D-Sweeper\Video"
    
    



Authenticity:

Please take note: Below is a PGP encrypted message. Only the original author can decrypt this message, as only the original author has access to the secret key that is needed to decrypt it. Also, unless this PGP message is included in this file, the hash values of this file (MD5, SHA-256) will not match up with the authentic hash values that are posted along with D-Sweeper. Therefore, authenticity and original ownership are guaranteed.
MD5: 2f2fdd442a4853f09055de4ab84396aeSHA-256: 800d3cf0c159bca9dd2e979b3223fa6ff278adfbeb622750dbffbcfc21930db2

-----BEGIN PGP MESSAGE-----
Version: GnuPG v2.0.14 (MingW32)

hQEMAyR0JCQV5M/xAQf9FD2JyGsyzTHefCeqOouEehTLhyWw+CpdxBBkHj3Pyi/c
dmQ799qkG4UNiRFTDwRBHygAhHFyJ9o2msUJmxYLqeNiHWnVEBqReUCVcXCN7la5
aAwVavKugr3zgtTXQCeobQt5S6vZmEWv9PM5NMb3Mwhw8puRUvc67OWRhZvxrudy
T/ENasU6Ruimxs9tuRINJsxJ+mYJYK+QxI0fgyr7F0q9ORvgo4xktFNdaX5iz8pd
aHrpF5LRlLvLVXZrgvGpN8l+WmI61TOPpej7Tf9W9ksQlEsOGihNDAVN0bkMEkv5
LOw3ySW1ia7tyXjdFFxGkaUepcJFSMrR3XuXjwMxmtLAmQHxKyxFiV7Hbk+e55dh
k4/a1Nnr9xUgIXxOAAy9n2plMa50U36KxgqjpsmU54Qu2wWJzRlQdLLEsjANs/50
7UpPUd0nYaPzgak7YLE2jCTc54IBEd70b0v7OguYDNNR6MLKHfRt+kE0oNhm9cLM
IgqU6VQxrKro1W2XvElC3ONGPOcSh+BmKENE+AGgutzxwhfwr2mPguqAnyENLFhY
1Q2HJ9uBEOfGlZyI5VcOOFYwR2wIPmvrCh80Kj71K+W+nT4txrAgBu3fg/AhIlo2
4K1/wRl/HukQ5QdMFONNylVIW71NmQz2xt8kbp7mgGcptM64f12maQ4sMRFyWxGu
ExdHXzTXtova9RjPcMpAM5c+CDoUE4803ycLW94/lGnKn/3z13SqxCFW0VX9eYoO
Rtyi9GSXZIpVCeJrmsYvHzSp7wicnz1aU1/aYC1duskwcUJGrL+sM153gQ==
=QZRN
-----END PGP MESSAGE-----

Happy Sweeping 

Search

Followers