Filemaker或applescript计算,用于在导出容器时识别和添加正确的文件扩展名

Filemaker或applescript计算,用于在导出容器时识别和添加正确的文件扩展名,applescript,acrobat,filemaker,Applescript,Acrobat,Filemaker,我有多种混合介质存储在我试图导出和打开的容器字段中(主要使用adobe Acrobat)我在导出这些文档时遇到问题,因为很多文档没有文件扩展名,或者在导出时重命名它们并添加扩展名(如.PDF),这通常与实际文件类型不兼容。在尝试打开时,acrobat会发出错误消息。。。我们是否可以在导出时使用函数、插件或计算来正确识别文件类型并在文件名末尾添加扩展名?您可以使用名称扩展名属性: tell application "Finder" to set nameEx to name extension o

我有多种混合介质存储在我试图导出和打开的容器字段中(主要使用adobe Acrobat)我在导出这些文档时遇到问题,因为很多文档没有文件扩展名,或者在导出时重命名它们并添加扩展名(如.PDF),这通常与实际文件类型不兼容。在尝试打开时,acrobat会发出错误消息。。。我们是否可以在导出时使用函数、插件或计算来正确识别文件类型并在文件名末尾添加扩展名?

您可以使用名称扩展名属性:

tell application "Finder" to set nameEx to name extension of (choose file)
编辑

这将为您提供每个文件的路径和扩展名

set myFolder to (path to desktop folder as text) & "Print:"

tell application "Finder"
    set myfiles to files of folder myFolder as alias list
    repeat with myfile in myfiles
        set mycurrentfile to myfile as text
        --my batchprint(mycurrentfile) 
        set nameEx to name extension of myfile
    end repeat
end tell

要设置没有文件扩展名的图像的名称扩展名,请执行以下操作:

您可以使用unix命令“file”获取图像的类型(也可以处理PDF文档)

以下是一个例子:

set myFolder to (path to desktop folder as text) & "Print:"
set myfiles to list folder myFolder without invisibles
repeat with f in myfiles
    set tFile to myFolder & f
    set na_Ext to name extension of (info for file tFile)

    if na_Ext is missing value then -- no name extension
        set r to do shell script "/usr/bin/file " & quoted form of POSIX path of tFile -- get the type of this image
        if "PDF document" is in r then
            set na_Ext to ".pdf"
        else if "PNG image data" is in r then
            set na_Ext to "png"
        else if "TIFF image data" is in r then
            set na_Ext to "tiff"
        else if "JPEG image data" is in r then
            set na_Ext to "jpg"
        else if "JPEG 2000 image data" is in r then
            set na_Ext to "jp2"
        else if "Adobe Photoshop Image" is in r then
            set na_Ext to "psd"
        else if "PC bitmap" is in r then
            set na_Ext to "bmp"
        else if "GIF image data" is in r then
            set na_Ext to "gif"
        else if "SGI image data" is in r then
            set na_Ext to "sgi"
        else if "Targa image data" is in r then
            set na_Ext to "tga"
        end if

        if na_Ext is not missing value then
            tell application "Finder" to set name extension of file tFile to na_Ext -- set the name extension of this file
        end if -- else the type of this image is not in this script
    end if
end repeat

似乎无法使此命令生效。。不断返回错误并表示无法获取扩展名…???
将myFolder设置为(以文本形式指向桌面文件夹的路径)和“打印:”将myfiles设置为列出文件夹myFolder但不显示重复myfiles中的myfile将mycurrentfile设置为((myFolder作为字符串)和(myfile作为字符串))作为字符串批打印(mycurrentfile)告诉应用程序“Finder”将nameEx设置为myfile end repeat的名称扩展名
感谢您的建议您的代码编辑工作用于识别已具有扩展名的文件上的扩展名(意味着由于Finder首选项,JPG的扩展名不可见)扩展名出现在applescript结果窗口中,但没有附加实际文件的扩展名。。此外,当我使用get info命令并从文件中删除.jpg扩展名并再次测试脚本时,它无法确定返回“”的正确扩展名