Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Removing file extension in ASP
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

SimonT
Junior Member

United Kingdom
202 Posts

Posted - 08 June 2001 :  12:01:29  Show Profile
I have a question I am reading in the names of files in a folder eg John.jpg Bob.jpg James.jpg I then want to print them out again
but I want to strip off the file extension so I am then just left with just the file names eg John Bob James
Can any one show me how to do this ?

Doug G
Support Moderator

USA
6493 Posts

Posted - 08 June 2001 :  12:04:53  Show Profile
I haven't tried this, but you should be able to use the split function for this.

<%
Dim a
a = split(sFilename, ".")
response.write a(0)
%>


======
Doug G
======
Go to Top of Page

SimonT
Junior Member

United Kingdom
202 Posts

Posted - 08 June 2001 :  14:05:01  Show Profile
I think it is me just being stupid as usual I and doing some thing that I have not read up on on so I am make quite a few mastakes

<%@Language=JScript%>
<%
//the gallery folder
var GalleryFolder = "/test/st/galleries";

//determine gallery and picture
var thispic, thisgal;
thispic = Request("pic").Item;
thisgal = Request("gallery").Item;
if (!thispic) thispic = 0
else thispic = parseInt(thispic);

//enumerate files in folder
var photos = new Array(0);
var i = 0;

var fso = Server.CreateObject("Scripting.FileSystemObject");
var fld = fso.GetFolder(Server.MapPath('/test/st/galleries/' + thisgal));
var fc = new Enumerator(fld.files);
for (; !fc.atEnd(); fc.moveNext()) {
if ("jpgif".indexOf(fso.GetExtensionName(fc.item())) > -1) {
picfile = fso.GetFileName(fc.item());
if (String(picfile).substring(0,1) != '_') photos[i++] = picfile;
}
}
fc = null;
fld = null;
fso = null;

var picsrc;
if (i) picsrc = GalleryFolder + '/' + thisgal + '/' + photos[thispic];
else picsrc = '';

%>
<html>
<head>
<title>Test Gallery</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>



<body bgcolor="#000000" text="#FFFFFF" onLoad="go()">
<p align="center"><img src="<%=picsrc%>" border="0"></p>
<p align="center"><%

if (thispic)
Response.Write('<a href="view.asp?gallery=' + thisgal + '&pic=' + (thispic-1) + '">Prev</a> ');
Response.Write (' ' + photos[thispic] + ' ');
if (thispic+1 < photos.length)
Response.Write(' <a href="view.asp?gallery=' + thisgal + '&pic=' + (thispic+1) + '">Next</a>');

Dim a
a = split(spicsrc, ".")
response.write a(0)


%></p>



then call it
view.asp?gallery=women

where women is a folder in your GalleryFolder folder

Go to Top of Page

GBurch
Junior Member

United Kingdom
107 Posts

Posted - 09 June 2001 :  04:49:10  Show Profile
The reason it's not working, is that the code Doug G gave you is written in VBScript, and your page is written in JScript.

http://www.captgb.dabsol.co.uk
http://www.slipstreamservices.com
Go to Top of Page

SimonT
Junior Member

United Kingdom
202 Posts

Posted - 09 June 2001 :  11:16:29  Show Profile
opps should have said that i was working in Jscript :-( looks like it will be up to me to read up on jscript

How many times have you been tempted to kick the box?

How many times have you kicked the box?

How many times has the box kicked back?
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.29 seconds. Powered By: Snitz Forums 2000 Version 3.4.07