By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,610 Members | 2,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,610 IT Pros & Developers. It's quick & easy.

Hyper link that opens the newest file in a dir?

P: n/a
Off the wall question:

Is there a way to set a hyperlink so that it opens the newest file in a
directory?

Why: I have a page that is a link to a daily set of reports. A new report
gets output every single night with a new unique name like this:
applicationperformance032520050100.doc

Which is the Application performance report for March 25 2005 out put at
1:00 AM. Tomorrow, a newer report will be there titled:
applicationperformance032620050100.doc

I want to provide a link the "Yesterdays Report" without needing to go in
and edit the link every morning.

Any suggestions?

Thanks

--
Glenn

Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
In article <d2**********@fred.mathworks.com>, gl*********@mathworks.com
enlightened us with...

Any suggestions?


Perl, PHP, JSP, Cold Fusion, ASP...
Javascript if you're REALLY stuck for a server-side solution. A bit easier to
do server-side, IMO, but it could be done client-side, assuming the browser
supported it (most do).

Added advantage to server-side: it can tell you if the file is missing. JS
will only write the link.

--
--
~kaeli~
Any sufficiently advanced technology is indistinguishable
from magic.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2

P: n/a
"Glenn Mulno" wrote in comp.infosystems.www.authoring.html:
Is there a way to set a hyperlink so that it opens the newest file in a
directory?


Yes, certainly. Remember that href="..." doesn't necessarily
identify a particular static file, or even a file at all. It's
interpreted by the server. Use some special URL and set up the
server to recognize it as a command to find and serve up the newest
file in the directory. Sounds like a job for CGI or similar.

If you're asking can you do it client side, the answer is No: the
client doesn't have the necessary information.

--

Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
Jul 23 '05 #3

P: n/a
Glenn Mulno wrote:
Is there a way to set a hyperlink so that it opens the newest file in a
directory?
Yes, but not in the way you seem to be asking for. In the markup, you
could use a link like this:

<a href="/applicationperformance">Latest Application Performance Report</a>

When a user follows that link, the browser will send a request to the
server, and the server must then determine how to fulfil the request.
You cannot have the browser automatically append the date to the end of
the file URI for you, but even if you could, it wouldn't be reliable
anyway, since it would depend on the user's system having the correct
date set.
Why: I have a page that is a link to a daily set of reports. A new report
gets output every single night with a new unique name like this:
applicationperformance032520050100.doc
That's what makes ISO-8601 so useful. Instead of having a bunch of
numbers that don't seem to be in any logical order, it's easier if you
use YYYY-MM-DD hh:mm. eg. applicationperformance200503250100. That has
the advantage that sorting by file name also sorts by date. Anyway,
regardless of the odd date format you've chosen, you need to provide
some server side processing in order to map a request for
/applicationperformance to the latest file.

You could have applicationperformance.php (or .asp, .jsp or whatever
technology you want to use). You can use Multiviews (or an equivalent
for a non-Apache web server) so you don't have to include the file
extension in the URI.

Within this PHP file, the logic could work like this:

Get todays date.
Generate the filename for today.
(eg. applicationperformance + Month + Day + Year + Hour + Min + ".doc")
Check the file actually exists on the server.
ie. It could possibly be requested before today's report has been
generated and, if that is the case, yesterday's report should be
sent instead.
Either:
- Output the contents of the latest report file found.
- Send a 302 Found or 307 Temporary Redirect response to redirect the
user to the latest file.
I want to provide a link the "Yesterdays Report" without needing to go in
and edit the link every morning.


This could be done in a similar way to the latest report above.
Alternatively, you could use server side processing to automatically
generate the appropriate file name.

eg.
<a href="/applicationperformance<?php date("mdYHi"); ?>.doc">Latest
Application Performance Report</a>
--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Jul 23 '05 #4

P: n/a
Glenn Mulno wrote:
Off the wall question: Is there a way to set a hyperlink so that it opens the newest file in a
directory? Why: I have a page that is a link to a daily set of reports. A new report
gets output every single night with a new unique name like this:
applicationperformance032520050100.doc Which is the Application performance report for March 25 2005 out put at
1:00 AM. Tomorrow, a newer report will be there titled:
applicationperformance032620050100.doc


Why not generate applicationperformancecurrent, and have a script
rename it with the appropriate date when the next
applicationperformancecurrent is generated, 24 hours later? Might not
this be more logically handled at the file system level than at the web
access level? Sure, this is an HTML newsgroup (even though this is a
scripting question) -- but that doesn't mean that a more basic approach
isn't indicated.

--
Blinky Linux Registered User 297263
Who has implemented Usenet Solution #45933:
Now killing all posts originating at Google Groups

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.