applescript获取给定路径的文件名
我只需要获取所选文件夹的文件名applescript获取给定路径的文件名,applescript,Applescript,我只需要获取所选文件夹的文件名 tell application "Finder" name of files of folder (choose folder) -- names of files end tell 然而,我不能让它在给定的路径下工作,比如这个路径 set myfile to name of files of folder "~/Downloads/test/" 我经常使用POSIX path和其他工具,但我无法让它正常工作。请你再帮我一次好吗,谢谢。这就可以了:
tell application "Finder"
name of files of folder (choose folder) -- names of files
end tell
然而,我不能让它在给定的路径下工作,比如这个路径
set myfile to name of files of folder "~/Downloads/test/"
我经常使用POSIX path和其他工具,但我无法让它正常工作。请你再帮我一次好吗,谢谢。这就可以了:
tell application "System Events"
set downloadsFolder to path to downloads folder as text
-- display dialog downloadsFolder
end tell
tell application "Finder"
set myFileNames to name of files of folder (downloadsFolder & "test:")
log myFileNames
end tell
添加:
set thisLocation to "/Volumes/Data/"
tell application "Finder"
set myFileNames to name of files of folder (thisLocation as POSIX file)
log myFileNames
end tell
这应该可以做到:
tell application "System Events"
set downloadsFolder to path to downloads folder as text
-- display dialog downloadsFolder
end tell
tell application "Finder"
set myFileNames to name of files of folder (downloadsFolder & "test:")
log myFileNames
end tell
添加:
set thisLocation to "/Volumes/Data/"
tell application "Finder"
set myFileNames to name of files of folder (thisLocation as POSIX file)
log myFileNames
end tell
这应该可以做到:
tell application "System Events"
set downloadsFolder to path to downloads folder as text
-- display dialog downloadsFolder
end tell
tell application "Finder"
set myFileNames to name of files of folder (downloadsFolder & "test:")
log myFileNames
end tell
添加:
set thisLocation to "/Volumes/Data/"
tell application "Finder"
set myFileNames to name of files of folder (thisLocation as POSIX file)
log myFileNames
end tell
这应该可以做到:
tell application "System Events"
set downloadsFolder to path to downloads folder as text
-- display dialog downloadsFolder
end tell
tell application "Finder"
set myFileNames to name of files of folder (downloadsFolder & "test:")
log myFileNames
end tell
添加:
set thisLocation to "/Volumes/Data/"
tell application "Finder"
set myFileNames to name of files of folder (thisLocation as POSIX file)
log myFileNames
end tell
我无法将此功能用于外部卷,例如,将downloadsFolder设置为“volumes:Data:”的路径,因为textBTW as Editor具有内置的代码段,所以在脚本中按CTRL键可以查看它们。我在脚本中没有使用log,我们可以看到结果,那么为什么我们需要log?谢谢你可以用日志删除那一行。我通常出于教育目的插入它们。我无法将其用于外部卷,例如,将downloadsFolder设置为“volumes:Data:”的路径,因为textBTW as Editor具有内置代码段,所以在脚本中按CTRL键可以查看它们。我在脚本中没有使用log,我们可以看到结果,那么为什么我们需要log?谢谢你可以用日志删除那一行。我通常出于教育目的插入它们。我无法将其用于外部卷,例如,将downloadsFolder设置为“volumes:Data:”的路径,因为textBTW as Editor具有内置代码段,所以在脚本中按CTRL键可以查看它们。我在脚本中没有使用log,我们可以看到结果,那么为什么我们需要log?谢谢你可以用日志删除那一行。我通常出于教育目的插入它们。我无法将其用于外部卷,例如,将downloadsFolder设置为“volumes:Data:”的路径,因为textBTW as Editor具有内置代码段,所以在脚本中按CTRL键可以查看它们。我在脚本中没有使用log,我们可以看到结果,那么为什么我们需要log?谢谢你可以用日志删除那一行。我通常出于教育目的插入它们。