bianli(Server.MapPath("/")+"\pic")

InStrRev("abcd.jpg", ".") 计算出abcd.jpg中第一次出现.所在的位置是第几个字符=5

mid("abcd.jpg",1,4) 取前四位abcd

mid("abcd.jpg",5) 从五位往后取(包括第五位) .jpg

取前缀abc

FullPath = "abc.jpg"
f = mid(FullPath,1,InStrRev(FullPath, ".")-1)
Response.Write f

娶后缀jpg

FullPath = "abc.jpg"
f = mid(FullPath,InStrRev(FullPath, ".")+1)
Response.Write f

<%
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")'创建一个Folder对象
foldername=server.mappath("./")
Set MyFolder=MyFileObject.GetFolder(foldername)
i=0'循环显示其中文件夹
response.write "显示文件夹:"
For Each thing in MyFolder.subfolders
Response.Write("<br>"&thing)
i=i+1
Next
response.write "<br>共有"&i&"个文件夹"
response.write "<p>显示文件名"'循环显示其中文件
i=0
For Each thing in MyFolder.Files
Response.Write("<br>"&thing)
i=i+1
Next
response.write "<br>共有"&i&"个文件"
%>

<%
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")'创建一个Folder对象
Set MyFolder=MyFileObject.GetFolder(server.mappath("."))
For Each thing in MyFolder.Files
thing=mid(thing,InStrRev(thing, "\")+1)
f = mid(thing,InStrRev(thing, ".")+1)
Set Reg = New RegExp
Reg.Pattern="test"
Set Matche=Reg.Execute(thing) '正则匹配Matches.Count<1表示不选;Matches.Count>1 就是匹配到选中
Reg.Pattern="lin"
Set Matches=Reg.Execute(thing)
IF Matches.Count<1 And Matche.Count<1 And f="asp" And thing<>"lin.asp" And thing<>"tpl.asp" And thing<>"tiao.asp" And thing<>"master.asp" And thing<>"delete.asp" Then
Response.Write thing
Response.Write("<br>")
End If
Next
%>

------------------------------------------------------------------------------------------------------------------------------------

生用的遍历文件:

<%@language="vbscript" codepage="65001"%>
<%
Response.Expires = 0
function bianli(path)
dim fso 'fso对象
dim objFolder '文件夹对象
dim objFiles '文件集合
dim objFile '文件对象
set fso=server.CreateObject("scripting.filesystemobject")
on error resume next
set objFolder=fso.GetFolder(path)'创建文件夹对象
set objSubFolders=objFolder.Subfolders'
for each objSubFolder in objSubFolders
nowpath=path + objSubFolder.name + "\"
Response.Write nowpath
set objFiles=objFolder.Files
for each objFile in objFiles
Response.Write (objFile.name)
Response.Write "<br/>"
Next
bianli(nowpath) '调用递归
next
set objFolder=nothing
set objSubFolders=nothing
set fso=nothing
end function
%>
<%
bianli(Server.MapPath("/") + "/new") '调用bianli()函数,这里是遍历当前目录下的new文件夹
%>

----------------------------------------------------------------------------------------------------

<%
Set fso=Server.CreateObject("Scripting.FileSystemObject")'创建一个Folder对象
fpath="."'Request.form("fpath")
set objfolder=fso.getfolder(server.mappath(fpath))
for each objsubfolder in objfolder.subfolders
Response.write "子文件夹名称:" & objsubfolder.name & "<br>"
next
Response.write "<br>"
for each objfile in objfolder.files
Response.write objfile.name & "<br>"
exitname=fso.GetExtensionName(objfile.name)'文件后缀也可以用这获取f = mid(thing,InStrRev(thing, ".")+1)'取asp后缀的文件 f="asp"
response.Write exitname & "<br>"
next
set objfolder=nothing
%>

-----------------------------------------------------------------------------------------
<%
Sub GetFolderObj(FD_getfolder)
For each SFolder in FD_getfolder.subfolders
call GetFileObj(SFolder)
call GetFolderObj(SFolder)
Next
End Sub

Sub GetFileObj(FD_getfile)
WritePath(FD_getfile)
For each MF in FD_getfile.files
call WriteFileMes(MF)
Next
End Sub

Sub WriteFileMes(MyFileObj)
%>
<tr bgcolor="#FFFFD0">
<td><%=MyFileObj.name%></td>
<td><%=MyFileObj.size%></td>
<td><%=MyFileObj.DateCreated %></td>
<td><%=MyFileObj.DateLastAccessed%></td>
<td><%=MyFileObj.DateLastModified%></td>
<td><%=MyFileObj.Type%></td>
</tr>
<%
End Sub

Sub WritePath(FDObj)
%>
<tr>
<td colspan="6" bgcolor="#81BDD3" ><%=FDObj.path%>下面的文件有:</td>
</tr>
<%
End Sub

Sub main()
Set fso =Server.CreateObject("Scripting.FileSystemObject")
Set PFD=fso.getfolder(server.MapPath("."))
Response.Write("<table>")
call GetFileObj(PFD)
call GetFolderObj(PFD)
Response.Write("</table>")
End sub
%>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>所有文件</title>
<style type="text/css">
<!--
td {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</head>

<body>
<% call main() '调用主程序 %>
</body>
</html>

-----------------------------------------------------------------------------------------

asp读取指定目录下的文件名的更多相关文章

  1. Java 读取指定目录下的文件名和目录名

    需求:读取指定目录下的文件名和目录名 实现如下: package com.test.common.util; import java.io.File; public class ReadFile { ...

  2. Python--通过索引excel表将文件进行文件夹分类的脚本+读取指定目录下所有文件名的脚本

    1.通过索引excel表将文件进行文件夹分类的脚本,此脚本由于将ip和id对应并生成对应id的文件夹将文件进行分类,也可以任意规定表格内容,通过vul_sc_ip.txt和xlsx文件进行索引. # ...

  3. python中获取指定目录下所有文件名列表的程序

    http://blog.csdn.net/rumswell/article/details/9818001 # -*- coding: utf-8 -*-#~ #------------------- ...

  4. iOS案例:读取指定目录下的文件列表

    // // main.m // 读取指定目录下的文件列表 // // Created by Apple on 15/11/24. // Copyright © 2015年 Apple. All rig ...

  5. python获取指定目录下所有文件名os.walk和os.listdir

    python获取指定目录下所有文件名os.walk和os.listdir 觉得有用的话,欢迎一起讨论相互学习~Follow Me os.walk 返回指定路径下所有文件和子文件夹中所有文件列表 其中文 ...

  6. 遍历并读取指定目录下的所有文件内容,写入Map集合然后输出在控制台和本地文件

    public class FileWrite { public static void main(String[] args) throws Exception { //封装数据源目录 File sr ...

  7. Python读取指定目录下指定后缀文件并保存为docx

    最近有个奇葩要求 要项目中的N行代码 申请专利啥的 然后作为程序员当然不能复制粘贴 用代码解决.. 使用python-docx读写docx文件 环境使用python3.6.0 首先pip安装pytho ...

  8. SAS 读取指定目录下文件列表宏

    OPTIONS PS=MAX LS=MAX NOCENTER SASMSTORE=SASUSER MSTORED MAUTOSOURCE;/*获取指定文件夹的指定类型的所有文件*/%MACRO GET ...

  9. java批量修改指定目录下的文件名

    package io; import java.io.File; import java.io.IOException; /** * @Auther: Code * @Date: 2018/9/9 1 ...

随机推荐

  1. 【Machine Learning in Action --3】决策树ID3算法预测隐形眼睛类型

    本节讲解如何预测患者需要佩戴的隐形眼镜类型. 1.使用决策树预测隐形眼镜类型的一般流程 (1)收集数据:提供的文本文件(数据来源于UCI数据库) (2)准备数据:解析tab键分隔的数据行 (3)分析数 ...

  2. 解决没有X11/Xlib.h 的错误

    1. 解决没有X11/Xlib.h 的错误Install XLib $sudo apt-get install libx11-dev 2. 提示错误:未找到软件源 解决办法很简单,更换另一个源就行了. ...

  3. 用http-server 创建node.js 静态服务器

    今天做一本书上的例子,结果代码不能正常运行,查询了一下,是语法过时了,书其实是新买的,出版不久. 过时代码如下 var connect=require('connect'); connect.crea ...

  4. mybatis------xml的一些规范等

    转与拼接: MyBatis 是支持普通 SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis 消除了几乎所有的JDBC代码和参数的手工设置以及结果集的检索.MyBatis 使用简单的 XML ...

  5. HDU 3338 Kakuro Extension

    网络最大流 TLE了两天的题目.80次Submit才AC,发现是刘汝佳白书的Dinic代码还可以优化.....瞬间无语..... #include<cstdio> #include< ...

  6. OpenLDAP安装与配置

    系统:ubuntu 14.04 安装: 1. sudo apt-get install slapd ldap-utils 2. 在1的过程中会让你输了admin密码 配置: 如果安装过,只是想配置Op ...

  7. 如何迅速成为Java高手[转]

    很多网友问我学习Java有没有什么捷径,我说“无他,唯手熟尔”.但是我却很愿意将自己学习的一些经验写出来,以便后来者少走弯路,帮助别人是最大的快乐嘛! 要想学好Java,首先要知道Java的大致分类. ...

  8. 通过C++修改系统时间代码

    #include <windows.h>#include <stdio.h>#include <iostream>using namespace std;int m ...

  9. MySQL-测试卷一

    MySQL-测试卷一 一.单项选择题 1 下面不属于Msql数据库特点的是(  ) A. 免费使用  B.不能跨平台  C.开源软件  D.功能强大 2 定义表的一个字段, 要求能表示4位整数,2位小 ...

  10. C# List<T> To DataTable

    public DataTable ConvertToDataTable<T>(IList<T> data) { PropertyDescriptorCollection pro ...