Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Modify text files without changing 'Date Modified' UNIX
I have been using Blosxom for my blogging purposes for a while and I really like the simplicity of it. You simply create text files and drop them into a specified directory and Blosxom does the rest. Unfortunately, it's a bit dumb in terms of files and modification dates. It sorts displayed items by the date they were modified. This creates a bit of a problem if you ever go back and edit an entry -- once saved, that entry gets bumped to the top again and dates as new. Now maybe this is what you want, but I personally do not. So I wrote this small shell script to edit my Blosxom entries with the BBEdit CLI and retain the original modification date upon saving it.

You could, of course, use this script for other purposes where you wish to maintain a file's original date and time stamp.
#!/bin/sh

# edit files with BBEdit without changing the modification date
# usage: blogedit file_to_edit

cp -p "$1" "$1.bak"
bbedit --resume --wait "$@"
touch -r "$1.bak" "$1"
rm "$1.bak"
    •    
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[12,604 views]  

Modify text files without changing 'Date Modified' | 5 comments | Create New Account
Click here to return to the 'Modify text files without changing 'Date Modified'' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Modify text files without changing 'Date Modified'
Authored by: dsf on Sep 01, '04 11:46:51AM

there's a blosxom plugin which caches the ctime (creation time) of each entry which obviates the need for this -- for this particular problem at least.

http://www.blosxom.com/plugins/indexing/entries_index.htm



[ Reply to This | # ]
Modify text files without changing 'Date Modified'
Authored by: Lathi on Sep 01, '04 01:23:05PM

Not to invite too many flames, there's some fairly simple <a href="http://www.lathi.net/twiki-bin/view/Main/EmacsAndBlosxom">elisp</a> to do the same thing in Emacs.

---
"Do well, be good, and keep in touch" -- Garrison Keeler



[ Reply to This | # ]
Modify text files without changing 'Date Modified'
Authored by: gvaughn on Sep 01, '04 05:14:21PM
Blapp is an editor for blogs that works well with Blosxom, and it has the ability to preserve modtimes, among others.

[ Reply to This | # ]
Modify text files without changing 'Date Modified'
Authored by: bluehz on Sep 01, '04 06:39:48PM

Yeah I Know about the plugin for Blosxom - but I started piling on addons, and then realized "hey, this is starting to defeat the purpose of why I wanted to use Blosxom - simplicty". I'm trying to run as clean a Blosxom as possible...



[ Reply to This | # ]
Modify text files without changing 'Date Modified'
Authored by: Anonymous on Sep 01, '04 09:42:00PM
Great lil script for when you're editing it locally.

I use a small perl script for when I want to fix something on my webhost (where my blog lives). It's just a little wrapper around stat and the editor of your/my choice (in this case, Pico.)

#!/usr/bin/perl

use File::stat;

$file = $ARGV[0];
if (!defined($file)) {
print "ERROR: Please enter a filename.\n";
}
else {
$mtime = stat($file)->mtime;
system 'pico', $file;
utime time, $mtime, $file;
}
I didn't want to go the plugin route on this either. I like the idea of moddates being used as post dates, but sometimes updates should not "float" to the top which disagrees with Rael's principle design. I don't need everyone to know I fixed a typo, though. :)

-cls

---
---

NOclsSPAM@the-cantina.com

(Remove the appropriate anti-spammy stuff to mail me.)

[ Reply to This | # ]