?
Solved

Batch to move files and folders

Posted on 2011-02-18
6
Medium Priority
?
1,042 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
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…
Suggested Courses
Course of the Month11 days, 21 hours left to enroll

752 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