Solved

Batch to move files and folders

Posted on 2011-02-18
6
1,041 Views
Last Modified: 2012-05-11
Dear Experts,

Today, and each Friday, I need to clean out my desktop files and folders which have filled my two 22inch screens since Monday. I use the desktop as a bit of a temp folder.

I was wondering if its possible to create a batch script which does the following;

1) Create a folder on the desktop named "Desktop BU" (but don't if it already exists)
2) Create a sub-folder in the Desktop BU folder which is named with a date stamp, in example "BU 18 Feb 2011" (or any other date format) (but don't if it already exists)
2) Move all files and folders (including all sub-folders and files) from the desktop to the folder created in step two (or the folder that already had that date stamp)

2A) Do not move certain Files, Folders, or Shortcuts. I can specify these as they will always be the same.

No rush with this one but much appreciated, by myself and undoubtedly many colleagues.

Thanks!

0
Comment
Question by:hendrkle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 9

Expert Comment

by:Tomas Valenta
ID: 34925022
Save the following script to file DesktopCleanup.cmd. This script is doing all except 2A. From moving is excluded only "Desktop BU" folder.
All other files is moved:

For /F "tokens=2 delims= " %%A in ('Date /t') do (SET CurrentDate=%%A)
mkdir "%USERPROFILE%\Desktop\Desktop BU\%CurrentDate%"
dir %USERPROFILE%\Desktop\ /S /B | find "BE2010" > %TEMP%\FileList.txt
For /F %%A in (%TEMP%\FileList.txt) do move %%A "%USERPROFILE%\Desktop\Desktop BU\%CurrentDate%\"
del %TEMP%\FileList.txt
0
 
LVL 9

Expert Comment

by:Tomas Valenta
ID: 34925027
Replace please text BE2010 with \Desktop BU\. I forgott change it from my testing environment.
0
 
LVL 9

Expert Comment

by:Tomas Valenta
ID: 34925042
If you would like to do also point 2A, send me please what files, folders or shortcuts you need to exclude
and I will change the code.
0
Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

 

Author Comment

by:hendrkle
ID: 34925304
Thanks Tominov,

I would like to keep:

Recycle Bin

Shortcuts:
Snagit 9
Mindjet MindManager Pro 6
VLC Media Player
VMware Workstation
Yahoo! Messenger
Cisco VPN
LiveMeeting
O Drive
Excel
PowerPoint
Word
Access
RADAR CRM
Java Web Start


Folders:

Bin


That's it

thank you sir!
0
 
LVL 9

Accepted Solution

by:
Tomas Valenta earned 500 total points
ID: 34925363
If you run in command prompt (Start/Run and here type cmd) this command: dir %USERPROFILE%\Desktop\
then you see what files are on your desktop from your profile. Programs create shortcuts on user desktop
but these shortcuts is mostly saved in another folder and you cannot see them in folder %USERPROFILE%\Desktop\.
Tell me what files you need to exclude from list created by command dir %USERPROFILE%\Desktop\.
0
 

Author Comment

by:hendrkle
ID: 34943762
Managed to do this myself at home - apologies for the late reply, thank you Tominov!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question