Archive for April, 2010

links for 2010-04-09

0 8 0
Saturday, 10th April 2010 delicious links Comments Off

links for 2010-04-01

0 8 7
Friday, 2nd April 2010 delicious links Comments Off

Renaming files (what I think is) the easy way

3 2 6

As much as a little part of me dies every time I’ve got to put a pdf file on a website, it does happen. And usually the file name sports non-web-friendly spaces, ampersands and annoying uppercased words. While people should be allowed to name things how they want, when files move from desktop to web there’s a right and a wrong way to do things, and I can never remember if it’s %20 or %20% for a hyperlink-able space.

So instead of trawling (alright then, after) for a application that would batch rename files, I wrote my own in 15 lines of PHP – download rename.php.txt. By giving you the line count I’m not claiming that I’m a PHP guru or anything, just that it’s really pretty easy to do this sort of thing without having to hand over any money.

All you have to do is put your human-readable pdfs in a folder in your PHP enabled webserver, put rename.php in the same folder, navigate to rename.php in a web browser and the job’s done (I keep a copy of the original pdfs in another folder in case something goes wrong). I’ve even added a bit more PHP that writes the html that you’ll need as a starting point, including the size of the file.

And the other good thing about this, even though I’ve been going on about pdfs, is that this script doesn’t care what sort of files they are. You could rename jpgs, pngs, whatever. And if you know a bit about string manipulation in PHP you can shorten file names to a particular length, add prefixes or suffixes, whatever you need for that particular job.

How to educate your end users to stop sending you pdfs and start sending you documents written for the web, properly formatted and marked up in html, is left as an exercise for the reader. Though if you have a script for that, please send me a copy. Please.

Thursday, 1st April 2010 web design Comments Off
Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License WordPress · Typekit · Dreamhost