AppleScript的得到一个文件夹的唯一文件名 [英] applescript get only file name of a folder

查看:542
本文介绍了AppleScript的得到一个文件夹的唯一文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下脚本,列出文件夹的内容(文件和文件夹的)

 设置the_files到(列表文件夹(选择文件夹)不隐身)

例如文件夹根目录有一个文件text1.txt和文件夹subroot2和subroot3

但如何我能得到的只是一个文件夹根目录的文件名(仅text1.txt)(不包括subroot2和subroot3)?谢谢


解决方案

 告诉应用程序发现者
    文件夹中的文件(选择文件夹) - 查找文件对象
    文件的名称 - (选择文件夹)文件夹的文件名
告诉结束

I have the following script that list the contents (files and folder) of a folder

 set the_files to (list folder (choose folder) without invisibles)

e.g folder root has a file text1.txt and folders subroot2 and subroot3

but how can I get just the file name (only text1.txt) of a folder root (exclude subroot2 and subroot3)? thanks

解决方案

tell application "Finder"
    files of folder (choose folder) -- Finder file objects
    name of files of folder (choose folder) -- names of files
end tell

这篇关于AppleScript的得到一个文件夹的唯一文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆