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

时间:2014-06-26 04:23:44

标签: applescript acrobat filemaker

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

2 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

设置没有文件扩展名的图片的名称扩展名:

您可以使用unix命令" file"获取图像的类型(也可以在PDF&#39文档上工作)。

以下是一个例子:

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