当前位置:首页>编程日记>正文

shell访问php文件夹,Shell获取某目录下所有文件夹的名称

Shell获取某目录下所有文件夹的名称以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!

shell访问php文件夹,Shell获取某目录下所有文件夹的名称 配图01

Shell获取某目录下所有文件夹的名称, 已知目录D:/temp,获取temp下所有文件夹的名称并输出,Shell怎么写?

方法有三,如下:

#!/bin/bash

#方法一

dir=$(ls -l D:/temp/ |awk '/^d/ {print $NF}')

for i in $dir

do

echo $i

done

#######

#方法二

for dir in $(ls D:/tmep/)

[ -d $dir ] && echo $dir

##方法三

ls -l D:/temp/ |awk '/^d/ {print $NF}'

## 其实同方法一,直接就可以显示不用for循环

php 获取目录下的所有文件夹名称

大致思路:

function traverseDir($dir){

if($dir_handle = @opendir($dir)){

while($filename = readdir($dir_handle)){

if($filename != "." && $filename != ".."){

$subFile = $dir.DIRECTORY_SEPARATOR.$filename; 要将源目录及子文件相连

if(is_dir($subFile)){ 若子文件是个目录

echo $filename.'
'; 输出该目录名称

traverseDir($subFile); 递归找出下级目录名称

}

closedir($dir_handle);

$dirNames = traverseDir("d:/dos"); 测试某目录

?>

VBS获取当前目录下所有文件夹名字

呵呵,原来是团友啊我写了一个!Set ws=WScript.CreateObject("wscript.shell")

w=ws.CurrentDirectory

Set fso=WScript.CreateObject("scripting.filesystemobject")

Set fs=fso.GetFolder(w)

Set f=fs.SubFolders

For Each uu In f

t=t & uu.Path & vbcrlf

Next

MsgBox t

使用VB获得目录下所有文件夹名称的问题

用FSO对象模型不是很好么,这种代码看的好痛苦哇!

C# 获取Ftp某个目录下的所有文件(不要文件夹)

我在之前做过一个FTP的客户端工具。

drw 文件夹

-rw 文件(有扩展名或无扩展名)

我是根据服务端返回的报文进行分析获取的列表。

给你一些代码片段:

/

/ 获取指定目录下的文件和文件夹。

/ 要获取的目录

/ 要发送到FTP服务器的密令。

public string[] GetFileList(string path, string WRMethods)从ftp服务器上获得文件列表

{

WebResponse response;

string[] downloadFiles;

int conut = 4;

StringBuilder result = new StringBuilder();

Connect(path);

if (FTPVariable.IsUseProxy_ftp)

reqFTP.Proxy = FtpProxy.GetFtpSelectProxy(FTPVariable.FtpCommand_transferProxyName);

reqFTP.ReadWriteTimeout = 12000;

如果不应销毁到服务器的连接,则为 true;否则为 false。默认值为 true。

reqFTP.Method = WRMethods;

try

response = (FtpWebResponse)reqFTP.GetResponse();

goto Ftp_lbl_03;

catch (WebException webex)

GetReply(webex.Message);

if (ReplyCode == 530) 未登录。

goto Ftp_lbl_04;

else if (ReplyCode == 550)

else

FtpManage.SetLog("获取列表超时,等候1秒后重试!");

goto Ftp_lbl_01;

Ftp_lbl_01:

FtpManage.SetLog("正在连接服务器 " + FtpRemoteHost);

response = GetRequest(path, WRMethods);

catch (WebException)

downloadFiles = null;

System.Threading.Thread.Sleep(1000);

if (conut == 0)

goto Ftp_lbl_02;

conut--;

catch (Exception ex)

MSG.Show(ex.Message, Global.GetRS["msgTilteError"], MessageBoxButton.OK, MsgIco.Error);

FtpManage.SetLog("命令执行失败,原因:" + ex.Message);

return downloadFiles;

Ftp_lbl_03:

StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);中文文件名

string line = reader.ReadLine();

while (line != null)

result.Append(line);

result.Append(" ");

line = reader.ReadLine();

if (result.Length == 0)

return null;

to remove the trailing ' '

result.Remove(result.ToString().LastIndexOf(' '), 1);

reader.Close();

response.Close();

FtpManage.SetLog("命令已成功执行");

return result.ToString().Split(' ');

Ftp_lbl_04:

FtpManage.SetLog(ReplyInfo);

Ftp_lbl_02:

FtpManage.SetLog("550 获取列表失败,无法连接远程服务器!");

FtpManage.ftpmanage.IsRefurbish = true;

public string[] GetFileList(string path)从ftp服务器上获得文件列表

return GetFileList(FTPVariable.FtpURLhead + FtpRemoteHost + "/" + path, WebRequestMethods.Ftp.ListDirectory);

public string[] GetFileList()从ftp服务器上获得文件列表

return GetFileList(FTPVariable.FtpURLhead + FtpRemoteHost + "/", WebRequestMethods.Ftp.ListDirectory);

/ 获取目录和文件名,返回目录表。

public string[] GetCatalog_FileList(string path)

string[] fountainhead = GetFileList(FTPVariable.FtpURLhead + FtpRemoteHost + "/" + path, WebRequestMethods.Ftp.ListDirectoryDetails);

string[] Catalog = null;

if (fountainhead == null)

Catalog = new string[fountainhead.Length];

for (int i = 3; i < fountainhead.Length; i++)

Catalog[i - 3] += fountainhead[i].Substring(55, fountainhead[i].Length - 55) + "&";FileName

Catalog[i - 3] += fountainhead[i].Substring(30, 12) + "&";FileSize

Catalog[i - 3] += fountainhead[i].Substring(42, 13) + "&";AmendDate

Catalog[i - 3] += fountainhead[i].Substring(0, 3) + "&";

return Catalog;

请问ASP中如何获取某个目录中所有文件夹的名称?

fso.GetFolder(path)

shell编程如何获取指定目录下所有文件的名称,例:目录:/root/dira/下的 001.DAT…009.DAT 9个文件名称?

你刚才不是问过了么?

vb 如何读取某目录下所有文件及子文件夹

查找某目录下所有 文件 及 子文件夹

试一试不用 FileSystemObject 对象,只用基本控件的代码。

'例子需控件:Command1,List1,List2,File1,Dir1,都采用默认属性。

'例如,查找 C: ,带 '** 的语可修改

Dim ctFind As Boolean

Private Sub Form_Load()

Me.Caption = "查找所有文件及文件夹"

Command1.Caption = "查找"

List2.Visible = False: File1.Visible = False: Dir1.Visible = False

Label1.Caption = "就绪"

End Sub

Private Sub Form_Unload(Cancel As Integer)

End

Private Sub Form_Resize()

Dim W As Long

On Error Resume Next

W = 720

List1.Move 0, 0, Me.ScaleWidth - W - 120, Me.ScaleHeight - 300

Command1.Move Me.ScaleWidth - W - 60, 300, W

Label1.Move 90, Me.ScaleHeight - 255, Screen.Width, 255

Private Sub Command1_Click()

ctFind = Not ctFind

If ctFind Then

Command1.Caption = "取消"

Call FindDirFile("C:") '**查找 C: 下的所有文件和目录,或 C:Windows 等

Else

End If

Private Sub FindDirFile(ByVal nPath As String)

Dim I As Long, nDir As String, Ci As Long

ctFind = True

List1.Clear: List2.Clear

If Right(nPath, 1) <> "" Then nPath = nPath & ""

List1.AddItem "查找 " & nPath: List2.AddItem nPath

File1.Pattern = "*"

File1.System = True: File1.Hidden = True: File1.ReadOnly = True

On Error GoTo Cuo

Dir1.Path = nPath

On Error GoTo 0

Do

If List2.ListCount = 0 Then Exit Do

nPath = List2.List(0)

List2.RemoveItem 0

For I = 0 To Dir1.ListCount - 1

GoSub ShowGe

nDir = Dir1.List(I)

If Right(nDir, 1) <> "" Then nDir = nDir & ""

List1.AddItem "■" & nDir

List2.AddItem nDir

File1.Path = nPath

For I = 0 To File1.ListCount - 1

List1.AddItem " " & nPath & File1.List(I)

Loop

Label1.Caption = "查找完毕,共找到 " & List1.ListCount & " 个条目"

ctFind = False

Exit Sub

Cuo:

List1.AddItem "起始目录不存在:" & nPath

ShowGe:

Ci = Ci + 1

If Ci < 99 Then Return

Ci = 0

Label1.Caption = "已找到 " & List1.ListCount & " 个:" & nPath

DoEvents

If ctFind Then Return

linux shell脚本怎么获取目录下所有txt文件名称

执行如下三条命令即可:

(1)、$script myresultfile

(2)、$ls -al *.txt

(3)、$exit

此时,该目录下的所有 txt 文件名称就会以长格式保存在 myresultfile 文件中了。

然后你再使用 SHELL 编程的功能把那些无用的列去掉即可。

分页:123


http://www.coolblog.cn/news/07abd26a23631885.html

相关文章:

  • asp多表查询并显示_SpringBoot系列(五):SpringBoot整合Mybatis实现多表关联查询
  • s7day2学习记录
  • 【求锤得锤的故事】Redis锁从面试连环炮聊到神仙打架。
  • 矿Spring入门Demo
  • 拼音怎么写_老师:不会写的字用圈代替,看到孩子试卷,网友:人才
  • Linux 实时流量监测(iptraf中文图解)
  • Win10 + Python + GPU版MXNet + VS2015 + RTools + R配置
  • 美颜
  • shell访问php文件夹,Shell获取某目录下所有文件夹的名称
  • 如何优雅的实现 Spring Boot 接口参数加密解密?
  • LeCun亲授的深度学习入门课:从飞行器的发明到卷积神经网络
  • Mac原生Terminal快速登录ssh
  • java受保护的数据与_Javascript类定义语法,私有成员、受保护成员、静态成员等介绍...
  • mysql commit 机制_1024MySQL事物提交机制
  • 支撑微博千亿调用的轻量级RPC框架:Motan
  • jquery 使用小技巧
  • 2019-9
  • 法拉利虚拟学院2010 服务器,法拉利虚拟学院2010
  • vscode pylint 错误_将实际未错误的py库添加到pylint白名单
  • 科学计算工具NumPy(3):ndarray的元素处理
  • 工程师在工作电脑存 64G 不雅文件,被公司开除后索赔 41 万,结果…
  • linux批量创建用户和密码
  • newinsets用法java_Java XYPlot.setInsets方法代碼示例
  • js常用阻止冒泡事件
  • 气泡图在开源监控工具中的应用效果
  • 各类型土地利用图例_划重点!国土空间总体规划——土地利用
  • php 启动服务器监听
  • dubbo简单示例
  • 【设计模式】 模式PK:策略模式VS状态模式
  • [iptables]Redhat 7.2下使用iptables实现NAT
  • Ubuntu13.10:[3]如何开启SSH SERVER服务
  • CSS小技巧——CSS滚动条美化
  • JS实现-页面数据无限加载
  • 阿里巴巴分布式服务框架 Dubbo
  • 最新DOS大全
  • Django View(视图系统)
  • 阿里大鱼.net core 发送短信
  • 程序员入错行怎么办?
  • 两张超级大表join优化
  • 第九天函数
  • HDU 5988 最小费用流
  • Linux软件安装-----apache安装
  • 《看透springmvc源码分析与实践》读书笔记一
  • Sorenson Capital:值得投资的 5 种 AI 技术
  • 正式开课!如何学习相机模型与标定?(单目+双目+鱼眼+深度相机)
  • Arm芯片的新革命在缓缓上演
  • nagios自写插件—check_file
  • 通过Spark进行ALS离线和Stream实时推荐
  • python3 错误 Max retries exceeded with url 解决方法
  • 行为模式之Template Method模式