How to Automatically create folders named by Date

How to Automatically create folders named by Date

Had an interesting scenario with an old Line of Business application for a client yesterday.

It was an old system that relied on Floppy Disks for Backups. The client was aware (due to my constant nagging!) that Floppy Disks weren’t to be trusted as a backup medium, and so had purchased a couple of USB Key-Disks to store the backups onto instead.

Fooling the system into thinking a USB disk was a Floppy was fairly simple, but where the system fell over was in the fact it didn’t overwrite the last backup… it simply threw a hissy-fit and crashed out!

Obviously, the client could manually delete the previous backup – but I looked for an automated solution.

The result? A small batch file that creates a folder within a sub-folder with that days date, with the batch-file set to “autorun” each and every time the USB Key Disk is inserted for the clients convenience.

Batch File:-

set dd=%date:~0,2%
set mm=%date:~3,2%
set yyyy=%date:~6,4%
mkdir “PayrollBackup%yyyy%-%mm%-%dd%”
move pay-data* “Backup%yyyy%-%mm%-%dd%”

Autorun File:-

[autorun]
open=Update.bat
action=Ready USB Disk for Backup
label=Backup

I don’t get many chances to write scripts nowadays, even very basic ones, so this was a good chance for me to get geeky. 🙂

RICHARD TUBB

Richard Tubb is one of the best-known experts within the global IT Managed Service Provider (MSP) community. He launched and sold his own MSP business before creating a leading MSP media and consultancy practice. Richard helps IT business owner’s take back control by freeing up their time and building a business that can run without them. He’s the author of the book “The IT Business Owner’s Survival Guide” and writer of the award-winning blog www.tubblog.co.uk

All Posts

You might like:

Super Top Tech For Your Pampered Pet Guinea Pigs image

Super Top Tech For Your Pampered Pet Guinea Pigs

Tech Guides | By Richard Tubb
How to monitor online mentions of your business with Google Alerts image

How to monitor online mentions of your business with Google Alerts

Building Relationships | By Richard Tubb
Here is a Google Script for using SaneBox alongside Unroll.me image

Here is a Google Script for using SaneBox alongside Unroll.me

Tech Guides | By Richard Tubb
How do I remove a LinkedIn contact? image

How do I remove a LinkedIn contact?

Tech Guides | By Richard Tubb

How to remove the Windows 10 Upgrade icon

Tech Guides | By Richard Tubb
What to do if you lose your Amazon Kindle image

What to do if you lose your Amazon Kindle

Tech Guides | By Richard Tubb
British Gas Hive Active Heating Review image

British Gas Hive Active Heating Review

Tech Guides | By Richard Tubb
How to build a high traffic blog on WordPress image

How to build a high traffic blog on WordPress

Tech Guides | By Richard Tubb
How to block Yesware from tracking you image

How to block Yesware from tracking you

Tech Guides | By Richard Tubb
Using a Three Home Signal Femtocell to improve a Mobile Phone Signal image

Using a Three Home Signal Femtocell to improve a Mobile Phone Signal

Tech Guides | By Richard Tubb
Taking a look at GFI EventsManager 2013 image

Taking a look at GFI EventsManager 2013

Tech Guides | By Guest Author
Recommended Podcasts for IT Professionals image

Recommended Podcasts for IT Professionals

Tech Guides | By Richard Tubb

Comments

2 thoughts on How to Automatically create folders named by Date

PAUL

4TH NOVEMBER 2008 14:53:30

Thanks for this, I adapated it to do something slighty different but your batch file gave me what I needed.  Thank you!

RICHARD

5TH NOVEMBER 2008 10:08:22

Paul - you're welcome, and glad you found it of use!

Leave a Reply

Your email address will not be published. Required fields are marked *

Share via
Send this to a friend