Solved

Batch to move files and folders

Posted on 2011-02-18
6
1,040 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
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…

730 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