Blosxom seems to be working for me quite well now that it started accepting comments. One of the features provides convenience but also brings with it a problem. It organizes each entry by the date it is posted. Each entry is a file, so it just reads the file date. Convenient.
I don't know about you, but sometimes I need to go back and adjust text or fix a spelling error. Mostly recently, I've been adjusting the framework of my setup that affects the way each entry is structured. So when I made a change, the system would rearrange the order of the entries. Problem.
My first thought was to search for an answer, but since I'm running on a Windows server, the chances of finding a utility on the Blosxom sites would be slim. This shouldn't be too difficult, I thought, so I wrote this filetime utility. I provide* it here for the ten or eleven folks out there who run Blosxom on a Windows server.
If you are wary of downloading an executable and running it on your system, then good for you and yes, you should be. So I'm guessing if you run Blosxom on a Windows server, then you also program in C#. For those folks, here's the source code:
static void Main(string[] args)
{
string strFile = String.Empty;
string strTime = String.Empty;
string strCurrentDir = System.IO.Directory.GetCurrentDirectory();
DateTime dt = new DateTime();
System.IO.FileInfo fi;
if (args.Length < 2)
{
prtheader();
prt(@"| filetime usage:");
prt(@"| ");
prt(@"| filetime <filename> <mm/dd/yy>");
prt(@"| filetime <filename> ""<mm/dd/yy hh:mm:ss>""");
prt(@"| -------------------- examples ---------------------");
prt(@"| filetime readme.txt 7/21/2004");
prt(@"| filetime ""read me.txt"" 7/21/2004");
prt(@"| filetime ""d:\driver files\read me.txt"" 7/21/2004");
prt(@"| filetime readme.txt ""7/21/2004 1pm""");
prt(@"| filetime readme.txt ""7/21/2004 1:45 pm""");
prt(@"| filetime ""read to me.txt"" ""7/21/2004 13:45""");
prt(@" ");
return;
}
strFile = System.IO.Path.GetFullPath(args[0]);
// check for absolute path
if (!System.IO.File.Exists(strFile))
{
// that didn't work. try looking in current directory
strFile = strCurrentDir + @"\" + args[0];
strFile = System.IO.Path.GetFullPath(strFile);
if (!System.IO.File.Exists(strFile))
{
// can't find it
prtheader();
prt("| filetime cannot locate file: " + strFile );
return;
}
}
try
{
// see if server understands the datetime entered
strTime = args[1];
dt = System.Convert.ToDateTime(strTime);
}
catch
{
// datetime is not meaningful
prtheader();
prt(@"| filetime does not recognize the timestamp: " + strTime);
return;
}
// as usual 95 percent input checking 5 percent work
// these two lines do the work...
// 1. create a FileInfo object for the file
// 2. set the LastWriteTime property to the desired datetime
fi = new System.IO.FileInfo(strFile);
fi.LastWriteTime = dt;
prt("last writetime set to: " + dt.ToString());
}
private static void prt(string s)
{
System.Console.Out.WriteLine(s);
}
private static void prtheader()
{
prt("| ");
prt("| filetime 1.0");
prt("| utility to change file last write time");
prt("| ");
prt("| Carl Camera iamacamera.org - provided as is - no warranty");
prt("| ");
prt("| ");
}
Download filetime utility: filetime.zip
* This utility is provided AS IS and by downloading it you agree to release me from any responsibility of damage it might cause on your system. The purpose of this utility is to adjust file dates for Blosxom entry text files only.