I'm using plain, vanilla Windows XP SP2. This is my work computer, so I'm a user, not an administrator--that is to say, I can't install anything.
In the course of my work, I (amongst other things) delete a directory with yesterday's date if it exists and create a directory with today's date. I'm looking for a way to automate this (and, eventually, other things, but this is the starting point). I use Linux and Mac OS X at home, so my first thought was to download Cygwin (which can just be run; it doesn't have to be installed) at
http://www.cygwin.com and write a quick Bash script:
#!/bin/bash
desktop="/cygdrive/c/Documents and Settings/carson/Desktop"
if [ -e $desktop/`date --date=yesterday +%Y%m%d` ]; then
rm -r $desktop/`date --date=yesterday +%Y%m%d`
mkdir $desktop/`date +%Y%m%d`
else
mkdir $desktop/`date +%Y%m%d`
fi
This failed to work because Cygwin doesn't handle spaces in directory names well (or at all). Also, the IT department (rightly, let it be said) wouldn't be pleased if they should discover me with unapproved programs. So I deleted Cygwin and started trying to write a batch file. Which meant I had to read up on it since the last time I wrote a batch file was, oh, 1994 or so.
With a little research, creating a directory with today's date is pretty easy:
@echo off
cd %USERPROFILE%\Desktop
mkdir "%DATE%"
Not the same date format as my Bash script above, but that doesn't matter since it's just to have a human read it, not to be parsed by anything. But I cannot for the life of me figure out how to test for the existance of a directory named for
yesterday's date. Can somebody help or point me in the right direction?