Benches macOS

5

Applescript to change file type using fol…

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

Just found out my Adobe Acrobat is saving PDFs with the filetype "FDP" and creator "ORAC" which is obviously the reverse of what they should be.

There doesn't appear to be a fix for this, and for me it's a problem because when I copy these PDFs onto our Xinet WebNative asset management server the files aren't recognised as PDFs, so don't display a preview in the web page.

So, I wanted to use a folder action that will set the Creator and Type to the PDFs whenever they are put into a folder on the server.

Unfurtunately, although I can get this to work when using a script in the form of an application (so I drop PDFs onto it, I cannot get it to work as a folder action. It doesn't set the creator and type even though the same commands in a application script do work.

*This is the code to my script which works fine as an application:*

====================

property FileType : ""

property CreatorType : ""

on open theFiles

tell application "Finder"

activate

set FileType to "PDF "

set CreatorType to "CARO"

repeat with eachFile in theFiles

set the file type of eachFile to FileType

set the creator type of eachFile to CreatorType

end repeat

end tell

end open

===================

*and this is what I'm trying to use for a folder action:*

===================

on adding folder items to my_folder after receiving the_files

set pdfs to {"pdf"}

repeat with i from 1 to number of items in the_files

tell application "Finder"

set this_file to (item i of the_files)

set the file_path to the quoted form of the POSIX path of this_file

--set the file_path2 to the quoted form of file_path --can combine if file_path isn't needed

set this_fileType to name extension of (info for this_file)

end tell

if this_fileType is in pdfs then

tell application "Finder"

activate

set FileType to "PDF "

set CreatorType to "CARO"

end tell

end if

end repeat

end adding folder items to

==================

I know it processes the file but it doesn't actually change the creator type.

*If only Apple would fix this bug in the first place!*

5 replies

Sign in or join Beachball Help to reply.

  1. 0

    red_menace

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Your folder action script
    isn't using the same commands, and doesn't do anything about setting file types or creator codes at all. Something like this should do the trick:

    <pre style="

    font-family: Monaco, 'Courier New', Courier, monospace;

    font-size: 10px;

    font-weight: normal;

    margin: 0px;

    padding: 5px;

    border: 1px solid #000000;

    width: 720px;

    color: #000000;

    background-color: #FFEE80;

    overflow: auto;"

    title="this text can be pasted into the Script Editor">

    on adding folder items to my_folder after receiving the_files

    set pdfs to {"pdf"}

    repeat with each_file in the_files

    set this_fileType to name extension of (info for each_file)

    if this_fileType is in pdfs then

    tell application "Finder"

    set file type of each_file to "PDF "

    set creator type of each_file to "CARO"

    end tell

    end if

    end repeat

    end adding folder items to

    </pre>

    ... and by the way, Apple doesn't have anything to do with the file types, creator codes, or other application specific settings that an Adobe application sets for itself.

  2. 0

    Phillip Briggs

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Thanks I'll give that a try.

    BTY reading the Adobe forums it seems to be Apple's problem - apparently this issue isn't limited to PDFs (Or Acrobat) but affects other files too. Seems to be something to do with Intel Macs: TYPE and CREATOR 'endianess'

  3. 0

    Phillip Briggs

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Brilliant!

    that worked a treat - thank so so much for your help, it will really help us out.

  4. 0

    Phillip Briggs

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Thanks

  5. 0

    Steve Mills

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Actually, it is Adobe's bug. They're the ones who are neglecting to swap bytes on the type and creator before passing it off to the File Manager when running on Intel.