Cleaning up desktop clutter the batch file way

As many of you may know I love batch files LOL Well I thought many people have an abundance of desktop clutter. The qustion is how to cut through the clutter and move only certain types of files to other locations and do it without installing any software? Well after a few hours I have solved the problem, using nothing else but a batch file. Before you ask, a batch file is a plain text file that allows you to run DOS style commands without having to type out commands multiple times. The following batch file will move any files with the .jpg, .jpeg, and .png file extensions to a folder called “Pic temp” in the folder “wow temp64″ on your desktop in Vista. You can modify the file as you wish to include other file extensions or send the files to another directory on your computer, even to removable devices (I.E. thumb/flash drives, memory cards, etc.)

Step one, the setup:

  • Create a folder on your desktop where you wish to send the files. (in the example below I use the folder called “wow temp64″ witch has a sub folder called “Pic temp” witch are on the C: drive)

Step two, the batch file:

  • Start off buy opening notepad (you can type into the run box “notepad” without the quotes)
  • Copy and paste in the following code replacing the xxxx with your username
    @echo off
    cls
    title trm96 CMC LLC Picture Mover
    if not exist c:\users\xxxx\desktop\*.jpg if not exist c:\users\xxxx\desktop\*.jpeg if not exist c:\users\xxxx\desktop\*.png echo Sorry, there are no files to move!
    if exist c:\users\xxxx\desktop\*.jpg move c:\users\xxxx\desktop\*.jpg c:\users\xxxx\desktop\"wow temp 64\pic temp"
    if exist c:\users\xxxx\desktop\*.jpeg move c:\users\xxxx\desktop\*.jpeg c:\users\xxxx\desktop\"wow temp 64\pic temp"
    if exist c:\users\xxxx\desktop\*.png move c:\users\xxxx\desktop\*.png c:\users\xxxx\desktop\"wow temp 64\pic temp"
    pause
    exit
  • Goto the file menu in notepad and click “Save as…”
  • Type in a file name (example “Move pictures.bat” (BTW you can use .cmd if you are using an NT biased OS like Win 2k, Win hexp, or Vista) this time include the quotes or notepad will save the file as “Move pictures.bat.txt”)

Step three, understanding whats going on:
Here is the breakdown as to whats going on so you can modify the code above to suit your needs.

  • @echo off
    cls
    I start all batch files with those two lines. Basically they make it so the command prompt window that comes up when you run the file doesn’t show the commands and clears the screen.
  • if not exist c:\users\xxxx\desktop\*.jpg if not exist c:\users\xxxx\desktop\*.jpeg if not exist c:\users\xxxx\desktop\*.png echo Sorry, there are no files to copy!This line makes it so if you run the batch when there are no files to move it will tell you
  • if exist c:\users\xxxx\desktop\*.jpg move c:\users\xxxx\desktop\*.jpg c:\users\xxxx\desktop\"wow temp 64\pic temp"
    if exist c:\users\xxxx\desktop\*.jpeg move c:\users\xxxx\desktop\*.jpeg c:\users\xxxx\desktop\"wow temp 64\pic temp"
    if exist c:\users\xxxx\desktop\*.png move c:\users\xxxx\desktop\*.png c:\users\xxxx\desktop\"wow temp 64\pic temp"
    These lines are the lines that do all the moving of the files. It first checks that there are files to move and then moves them to “c:\users\xxxx\desktop\wow temp 64\pic temp” folder. Please note that if the path either starting or destination contains spaces it has to be encased in quotes.
  • pause
    exit

    Those lines make it so you have to press a key to exit the batch. I included the “pause” so if there are any errors you will see that before the batch exits.
  • Well that’s all there is to it if you have any questions or comments then by all means please post them.



Written by Brett Pierce - Visit Website

Tags: , , , , , ,

  • http://radiant-ru.ru Arianaceab

    Nice ! Smile.. Thanks buddy..