标签:restrict javascript applet applescript
这个问题不仅限于了解AppleScript的人,如果您了解Cocoa等,您应该知道以下答案:
I’m making a droplet in AppleScript that compresses JavaScript files, so obviously, I only want JavaScript files to be allowed into the scripts. Any ideas?
非常感谢.
解决方法:
property kJavascriptExtension : "js"
property pValidFileList : {}
on open of theFiles -- Executed when files are dropped on the script
set fileCount to (get count of items in theFiles)
repeat with thisFile from 1 to fileCount
set theFile to item thisFile of theFiles
set theFileAlias to theFile as alias
tell application "Finder"
set fileInfo to info for theFileAlias
set fileName to name of fileInfo
end tell
set javascriptFileFound to isJavascriptFile(fileName) of me
if (javascriptFileFound) then
set end of pValidFileList to theFile
end if
end repeat
display dialog "pValidFileList = " & pValidFileList
-- do something with your files here
end open
on isJavascriptFile(theFilename) -- (theFilename as string) as boolean
set AppleScript's text item delimiters to "."
set fileNameList to every text item of theFilename
set AppleScript's text item delimiters to ""
try
set theFileExtension to item 2 of fileNameList as string
on error
return false
end try
if theFileExtension is kJavascriptExtension then
return true
end if
return false
end isJavascriptFile
标签:restrict,javascript,applet,applescript 来源: https://codeday.me/bug/20191009/1879267.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。