Solved

Batch to move files and folders

Posted on 2011-02-18
6
1,037 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
  • 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now