[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1044
  • Last Modified:

Batch to move files and folders

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
hendrkle
Asked:
hendrkle
  • 4
  • 2
1 Solution
 
Tomas ValentaCommented:
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
 
Tomas ValentaCommented:
Replace please text BE2010 with \Desktop BU\. I forgott change it from my testing environment.
0
 
Tomas ValentaCommented:
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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
hendrkleAuthor Commented:
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
 
Tomas ValentaCommented:
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
 
hendrkleAuthor Commented:
Managed to do this myself at home - apologies for the late reply, thank you Tominov!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now