Applescript to change file type using folder action

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!*

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.

Similar Messages

  • Changing file type association through java

    hello all,
    here i had a problem like , we know when we try to open .csv file by default it wll open in excel , because the csv file type was associated with excel this we can see in mycomputer->tools->folder options->file types and here we even have the possiblity of changing the association.
    anyway, my question is that is there any way of changing this association like csv to oepn in wordpad through java program
    with regards
    satya

    i created a like wordCsv.reg
    REGEDIT 4
    [HKEY_CLASSES_ROOT\.csv]
    "Default"=string:Wordpad.Document.1
    when i click on this file i could see a message that the entry wassucessfully entried but i cannot see the entry
    is my approach was correct in adding entry in regedit programatically,
    please any more ideas
    http://jniwrapper.com/pages/winpack/downloads
    here in this link i saw some samples regarding changing file types association
    , dont now will it works
    since this is for win32
    i found a program FileTypeAssociation dont know will it works
    * Copyright (c) 2002-2005 TeamDev Ltd. All rights reserved.
    * Use is subject to license terms.
    * The complete licence text can be found at
    * http://www.jniwrapper.com/pages/winpack/license
    package com.jniwrapper.win32.shell;
    import com.jniwrapper.Function;
    import com.jniwrapper.LongInt;
    import com.jniwrapper.Pointer;
    import com.jniwrapper.UInt;
    import com.jniwrapper.win32.registry.RegistryKey;
    import com.jniwrapper.win32.registry.RegistryKeyType;
    import com.jniwrapper.win32.registry.RegistryKeyValues;
    import com.jniwrapper.win32.registry.RegistryException;
    import java.io.File;
    * This class provides functionality for creating file type associations.
    * @author Vladimir Kondrashchenko
    public class FileTypeAssociation
    private static final String FUNCTION_SHCHANGENOTIFY = "SHChangeNotify";
    private static final long SHCNE_ASSOCCHANGED = 0x08000000L;
    private static final long SHCNF_IDLIST = 0x0000;
    private String _extention;
    * Creates a class instance for associating files of the specified type.
    * @param extention specifies the file type by its extention.
    public FileTypeAssociation(String extention)
    if (extention.startsWith("."))
    _extention = extention;
    else
    _extention = "." + extention;
    * Creates a file type association.
    * @param executable an associated file will be passed as a parameter of this executable file.
    * @param progID the programm identifier in the registry. If the specified prog ID is not exist, it
    * will be created.
    public void createAssociation(File executable, String progID)
    if (!executable.isFile())
    throw new IllegalArgumentException("File not found.");
    String commandLine = "\"" + executable.getAbsolutePath() + "\" \"%1\"";
    createAssociation(commandLine, progID);
    * Creates a file type association.
    * @param commandLine specifies an executable command.
    * @param progID the executable programm identifier in the registry. If the specified prog ID is not exist, it
    * will be created.
    public void createAssociation(String commandLine, String progID)
    RegistryKey registryKey = RegistryKey.CLASSES_ROOT.createSubKey(progID+"\\shell\\open\\command", true);
    RegistryKeyValues values = registryKey.values();
    if (commandLine != null)
    values.put("", commandLine);
    else
    values.put("", "");
    registryKey.close();
    registryKey = RegistryKey.CLASSES_ROOT.createSubKey(getExtention(), true);
    values = registryKey.values();
    values.put("", progID, RegistryKeyType.SZ);
    registryKey.close();
    changeNotify();
    * Removes all associations for the file extention.
    public void removeAssociation()
    try
    RegistryKey.CLASSES_ROOT.deleteSubKey(getExtention());
    catch(RegistryException e)
    try
    RegistryKey.CURRENT_USER.openSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts").
    deleteSubKey(getExtention());
    catch(RegistryException e)
    try
    RegistryKey.LOCAL_MACHINE.openSubKey("SOFTWARE\\Classes").deleteSubKey(getExtention());
    catch (RegistryException e)
    changeNotify();
    * Returns the default executable command for the file extention.
    * @return the default executable command for the file extention.
    public String getDefaultCommand()
    RegistryKey key = RegistryKey.CLASSES_ROOT.openSubKey(getProgID());
    key = key.openSubKey("\\shell\\open\\command");
    RegistryKeyValues values = key.values();
    return values.get("").toString();
    * Returns the program identified of the default executable program.
    * @return the program identified of the default executable program.
    public String getProgID()
    RegistryKeyValues values = RegistryKey.CLASSES_ROOT.openSubKey(getExtention()).values();
    return values.get("").toString();
    * Returns <code>true</code> if a file type association for the specified extention is registered.
    * @return <code>true</code> if a file type association for the specified extention is registered.
    public boolean isRegistered()
    try
    RegistryKey.CLASSES_ROOT.openSubKey(getExtention());
    catch (RegistryException e)
    return false;
    return true;
    * Returns the file extention.
    * @return the file extention.
    public String getExtention()
    return _extention;
    private void changeNotify()
    Function function = Shell32.getInstance().getFunction(FUNCTION_SHCHANGENOTIFY.toString());
    function.invoke(null,
    new LongInt(SHCNE_ASSOCCHANGED),
    new UInt(SHCNF_IDLIST),
    new Pointer(null, true),
    new Pointer(null, true));

  • Where is "save as" or how to change file type in Preview in Lion?

    Where is "save as" or how to change file type in Preview in Lion? I used to use Preview to change quickly change a lot of PNGs to either JPEGs or PDFs but with the introduction of versions auto save etc there no "save as" in the File menu. Any suggestions how to get this functionality back or how to get around it within OS X (no Photoshop etc)?

    Just wasted 15 minutes looking for that.  What's wrong with Save As?

  • Change file type to pdf

    How do I change file type to pdf with windows 8 without paying? I was able to do this with windows 7 without paying.

    Actually, I guess it's possible you were using paid-for Adobe software and didn't realise it.
    Can you remember the steps you followed to make a PDF in your old system?

  • Applescript to change image resolution using image events

    Does anyone have an applescript to change image resolution using image events in OSX? I want to optimize my images for iWeb. I want to use a shell script in an applescript as a droplet or as a service in Automator. I'd like to leave the original intact.

    For what type of use in iWeb are these photos intended? If it's for adding to a page (not a photo or album page) iWeb does a great job of optimizing. See my post in this topic: Re: Photo Resolution in iWeb.
    You can optimize an entire site with an application like Web Site Maestro. It can reduce the site's size by up to 49%. Here's the settings available for the optimization:
    Click to view full size
    It's very effective.
    OT

  • In finder cannot easily change files from one folder to another. Drag and drop does not work. There should a cut and paste feachure.

    In finder I cannto easily change files from one folder to another.  There should de a cut and paste for this.  Not drag and drop. thanks P.

    paulfromqueretaro wrote:
    In finder I cannto easily change files from one folder to another.  There should de a cut and paste for this.  Not drag and drop. thanks P.
    OS X is all about keyboard shortcuts.
    To cut       cmd+x
    To copy     cmd+c
    To paste    cmd+v
    With the Mouse, hold command and drag to your destination.

  • Changing file type when saving doesn't work

    How can I fix the problem where, if I change file type when saving, eg from tiff to jpg, the 'jpg' suffix is not appended in the save window? It remains as tiff. This has only started happening recently.

    I have a G5 iSight running OSX 10.4.11 with all the latest upgrades. The problem is about a week old.
    Yesterday I did a clean install of everything (not because of this problem) which I'm sure would have cleared the problem. But I was playing around with importing all my old PS and InDesign settings via copying the old preference files (and others), and the tiff/jpeg problem has reappeared. Seems to me like one of the files I copied, contains the problem. I suspect the only way out of this is to reload PS. But I was hoping it might be as simple as deleting a certain preference file.

  • Change file mode using java?

    Hi
    Can I change file mode using java method other than
    Runtime.exec()
    thx
    Jacinle

    Hi
    Thank you Roopasri. But what I want is not using Runtime.exec
    I am using Unix and I want to change some image file access mode
    so not a RandomAccess File.
    So is there anything like chmod command on Unix?
    something like maybe java.io.File.chmod("755");
    I read that's a feature requested early on 1.2
    Will it be included in 1.4?
    Jacinle

  • Help on moving specific files using folder actions

    so i want to move all downloaded files that have the extension .pdf to a folder in my docs but it doesnt always work and if i download 2 at once it fails. im new to applescripts so please help!
    this is what i have:
    on adding folder items to this_folder after receiving added_items
    tell application "Finder"
    repeat with all_items in this_folder
    if the name extension of any_item is "pdf" then
    move item to folder "Macintosh HD:Users:Campbell:Documents:Printing"
    end if
    end repeat
    end tell
    end adding folder items to

    As written, you are referring to different variables in your repeat loop for the added items (all_items, any_item, etc). The loop variable you define in the repeat statement is the one to use.
    Snow Leopard added a time delay to check if items are still being downloaded, but in Leopard you will need to do it yourself. The following script adds a wait handler that will wait for files to be downloaded (I also threw in a run handler for testing):
    <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; height: 340px;
    color: #000000;
    background-color: #DAFFB6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    property destination : "Macintosh HD:Users:Campbell:Documents:Printing"
    property someTime : 60 -- time (in seconds) to allow files to copy/download
    on run -- application double-clicked or run from the Script Editor
    set theFolder to (choose folder)
    tell application "Finder" to set theItems to files of theFolder as alias list
    adding folder items to theFolder after receiving theItems -- process entire folder contents
    end run
    on adding folder items to this_folder after receiving added_items -- folder action
    if (waitForFilesToCopy into this_folder for someTime) then
    doStuff for added_items
    else
    display alert "Folder Action error" message "File copy/download into folder " & quoted form of POSIX path of this_folder & " did not complete in the time allowed."
    end if
    end adding folder items to
    to doStuff for someFiles
    do stuff with each file in someFiles
    parameters - someFiles [list]: a list of files to do stuff with
    returns nothing
    repeat with anItem in someFiles
    tell application "Finder"
    if the name extension of anItem is "pdf" then
    move anItem to folder destination
    -- move anItem to (path to desktop) -- testing
    end if
    end tell
    end repeat
    end doStuff
    to waitForFilesToCopy into someFolder for timeToWait
    checks every interval seconds up to timeToWait for files to be copied/downloaded to theFolder
    the test is based on the size of the folder not changing after interval seconds
    parameters - someFolder [mixed]: the folder to check
    timeToWait [integer]: a maximum timeout value in seconds
    returns [boolean]: true if copy/download finished, false if timeout
    set interval to 2 -- adjust as desired
    set someFolder to quoted form of POSIX path of someFolder
    set currentSize to first word of (do shell script "du -s " & someFolder) -- get initial size
    repeat with timer from timeToWait to 1 by -interval
    delay interval
    set newSize to first word of (do shell script "du -s " & someFolder) -- recheck size
    if (newSize is equal to currentSize) then
    return true -- success
    else -- update size
    set currentSize to newSize
    end if
    end repeat
    return false -- timed out
    end waitForFilesToCopy
    </pre>

  • Processing a File (From a Folder Action) Through an AppleScript

    I have a Folder Action enabled which automatically uploads images placed in a folder to a FTP server. It works great when I'm at home on my own network, but if I'm somewhere with a firewall that prohibits connecting to my FTP server (i.e. work) or if I am not connected to the internet, the folder action will still run but my images will never get uploaded.
    I've attached a screenshot of my workflow. The folder action gets the image added to the folder, copies the original to a different folder, and then scales the image down to a smaller size before uploading it. I'm using the upload workflow action from Transmit.
    I figured I could use an AppleScript to check whether or not my computer can reach the ftp server and then wait until it was connected to run the rest of the workflow if it can't reach the server:
    repeat with i from 1 to 86400
        try
            do shell script "ping -o ftp.examplewebsite.com"
            exit repeat
        on error
            delay 5
            if i = 86400 then error number -128
        end try
    end repeat
    The only problem is, I'm pretty inexperienced with AppleScript and am not really sure how or where to insert it into my workflow to get the image to "pass through" the AppleScript. Currently, whenever I include this AppleScript in my workflow, before the Upload action, for example, the image ends up not getting passed through the AppleScript and it doesn't get uploaded as a result.
    Hopefully this a fairly simple question and someone can help me out, or if there's an easier way to delay running a folder action until I can connect to the server someone will let me know. I can clarify anything if necessary.

    Good job
    I just saw this…
    applescript in automator - stop a workflow
    It kills the workflow based on a test, so I tried this…
    Here is the text if you want to copy & paste. It will fail on Apple.com & stop the workflow. Success should allow it to continue.
    on run {input, parameters}
      try
      set pinged to do shell script "ping -c 3 -q  apple.com "
      if pinged is equal to 0 then
      return input
      end if
      on error
      error number -128 -- exit by user-cancel
      end try
    end run
    on run {input, parameters}
       display dialog "Rest of script will now continue..."
      return input
    end run

  • Old icons remain after changing file type association

    I have several video file types in my Movies folder: MPG, MP4, AVI, and MKV.  Many of the file types are automatically associated with Quicktime Player, (despite it being unable to process them, such as the AVIs).  Being unable to play my MKVs at all, I downloaded VLC player to supplement.  I have since grown to like the additional features of VLC, and would like to use it as my player of choice for all movie files.
    Changing the file type associations was simple enough, (Get Info -> Open With, Set as default for each file type), however the pre-associated files still retain their original QT icon.
    How do I go about batch changing the incorrect QT-associated finder icons for icons that correctly represent their new association with VLC?
    Thanks for reading

    I was having that same trouble, but with ".rar" archives (in my case - OS X Yosemite), I tried all ways to solve it, following all kind of tips, like: choosing a new program as default to open the file, app cleaners, terminal commands, disk utility, etc.. but nothing worked. When finally I got problem solved, how I did it: 1) Download the program: Cocktail (http://www.maintain.se/cocktail/), after downloading, I got the message to register it, I simply clicked on "Remind me later". 2) Now, after installing it, configure Cocktail with this short tutorial, exactly as described (http://www.everythingmacintosh.com/tech-notes/maintain-your-mac-with-mac-os-x-co cktail/). After following 2 steps, Cocktail will be configured and will run, in the end your Mac will restart, you can now check that all your archives will be with correct icon (preview/thumbnail). Hope it helps!

  • Windows BUG: Can't change file types through control panel Quicktime settings

    I am running the latest version of Quicktime on Viista Home Premium 64-bit.
    When I into Control Panel -> View 32-bit Control Panel Items -> Quicktime -> Browser, and I click on "File Types" or "MIME Settings", I get a blank page that looks like this: http://oi40.tinypic.com/hvbbia.jpg, and Quicktime momentarily freezes.
    I have no issue adjusting file type settings when bringing up Quicktime outside of control panel, or when using "Default Programs" within control panel, it's only when I do it within "View 32-bit Control Panel Items" that it does this.
    This is a minor bug but still weird. Can anyone else verify the issue? I tried uninstalling and reinstalling but that didn't help.

    This could be caused by damaged QuickTime preference files (or possibly a permissions problem on the preferences files).
    We can try rebuilding one set of your preference files to see if that helps with the greyed-out stuff.
    First, quit QuickTime if you have it open.
    Next, you'll need to make sure you are set up to view hidden files and folders in Vista (or 7).
    1. From the Start menu, click Open.
    2. In the Organize menu, click Folder and Search Options.
    3. Click the View tab.
    4. In the "Advanced settings" pane under "Hidden files and folders" make sure that the "Show hidden files and folders" option is selected.
    5. Click OK.
    Next, you'll remove the QuickTime preference folder (and contained file).
    6. In Computer, open Local Disk: C or whichever drive your documents are stored on.
    7. Open the Users folder.
    8. Open the folder with the name of the Windows 7 user account in which the QuickTime file types are "greyed out".
    9. Open the AppData folder.
    10. Open the Local folder.
    11. Open the Apple Computer folder.
    12. Drag the QuickTime folder out onto the Desktop.
    Now you'll rebuild the preference folder and file.
    13. Launch QuickTime. Check your file types again.
    Are they still greyed out, or can you change them now?

  • Changing "file type" in Link Information Window (CS3)

    Hola,
    I am having a problem in Indesign (CS3), and I was wondering if anyone here might be able to help.
    I'm a student updating an older .INDD file for a 47 page book. The pages were all updated as .AI files, but for some reason
    3 of the pages in our InDesign document were assigned a .PDF "file type" in the Link Information window.  When I try and "Relink" to the updated .AI files,
    the program won't link to the .AI file. It will properly re-link to a .PDF version of the file.
    Is there a way to reset that "file type" in the Links Window from .PDF to .AI?
    Ultimately I can use .PDF versions for this, but I'd prefer to have them all .AI files.
    That would be cleaner and easier for the next students down the road who are going
    to inheriet this project.  It seems like this should be an easy thing to do, but I can't figure it out...
    Thank you very much for any information you can provide.  
    ¡Muchas gracias!
    Javier

    Hola,
    Thank you for the quick reply!  I now suspect that I didn't correctly identify the problem.
    In the Links Panel for 44 of the 47 pages, they read pathname/*.AI, so no problem there (although the file type is also .PDF in the link window for those 44 pages that can link to the .AI).
    For three of the pages though, when I try and link them to pathname/*.AI, I get an error message in the document that indicates that "this is an Adobe Ilustrator file that was saved without PDF content".  When I relink those three to pathname/*.pdf, they work.
    So I'm thinking at this point that the problem isn't Indesign, but with the original .AI files that I'm trying to link to. I also suspect that my original idea to change the "file type" in the Links Panel to ".AI" is incorrect, since it's a .PDF file type for all of the 47 pages in this document!
    ¡Muchas gracias!
    Javier

  • Change file type classification? mkv as "Movie"

    In short, I would like to make mkv files show up under the class of "Movie" in smart folders and such. I'm assuming that buried in some setting or file there is a list of extensions I can add "mkv" to. I would have thought this was a common question but so far forum trawling has got me nowhere. Can anyone shed some light? The reason, if you care to read is below, but it doesn't have that much bearing on the question.
    I have a sizeable DVD collection, I also have a new job that puts me in hotels 5 weeks out of 6 for training. I don't want to carry them around as they'll get damaged and broken. Last week I left my MacPro chobbling away at encodes and now my entire DVD collection resides on a NAS as well as my shelves. I've created a simple automator finder service that will copy the selected files to a "Films" folder within the Movies folder that I've removed from the time machine backup so as not to waste space. This is set to only show up if the selected items are "Movies". As a consequence, it doens't appear for mkv's.
    I know I can just alter the service to be there permanantly which is what I'll do for now, but it's not a very elegant solution.

    I was able to change the extension in Windows, which then changed the file type. I'm still curious as to how to make the change directly on my MAC.

  • How to change file type associations in SAP ERP 6.0?

    Hello,
    I'd like to figure out how to change the application associated with a given file type in SAP. I want to open a .DOC file, but I am using OpenOffice instead of MS Word. I have .DOC file type already associated with OpenOffice in Windows XP, but SAP doesn't seem to recognize that association. I am using SAP ERP 6.0. Any ideas?
    Mike

    Hi,
    MS Word is mandatory. You will not be able to work using Open Office in SAP.
    Regards,
    Rajesh Kumar

Maybe you are looking for

  • Down Payments Query

    Client  has done a down payment Issued a purchase Order to a supplier supplier has invoiced in advanced in delivering the goods Supplier has invoiced 2 invoices for one purchase  order Client has made 1st payment using AP down payment invoice. They h

  • Exporting more than one address book at at a time

    How can a modern system such as mozilla not have a way to export and import all one's address books at one time. The old outlook was just one shot and done. So far the only way I can export or import address books is one at a time and I have 10 books

  • Importing sets "part of compilation" all the time, even when it shouldn't.

    I've just instaled iTunes 9.01 and have been importing about 5 CDs worth of music. The problem is that iTunes seems to be setting the "part of a compilation" flag every time even though none of the CDs I've been importing are compilations CDs. I know

  • Why i can't register to an appstore without a bankcard?

    so i bought my iphone 5s but when i want to register on the appstore i need a bankcard but i just click nex because im 16 years old and I DONT NEED bankcard but without a bankcard i can't register an appstore or the itunes

  • Can't get two airport expresses to work simultaneously

    Just added a second airport express (both 802.11n, both updated) solely to listen to music from iTunes. Non apple router. Both are working fine separately with green light on but when I try to play through both at once (using "multiple speakers") the