Pass Finder reference between Automator and Applescript

Hi - This is doing my head in !
I have an Automator script that encrypts a PDF and then runs an AppleScript within the Automator workflow that does a rename on the resultant encrypted PDF. The result of this workflow is a filename I need within another calling Applescript.
So in the Automator workflow I have the following code:
set the new_item to (move item target_name of the temp_folder to container of the source_item)
end tell
return new_item as alias
When I view the response in the calling Applescript I see this:
"{alias "Macintosh HD:Support:test-28 (encrypted).pdf"}"
How do I consume this in my Applescript ?? I need to get it into a POSIX format or something I can use.
This is my test Applescript:
http://bit.ly/fQ3s1i
This is the Applescript within the Automator workflow:
on run {input, parameters}
set the result_item to item 1 of input
set the source_item to item 2 of input
set the target_item to result_item
tell application "Finder"
set the temp_folder to the container of the target_item
copy my derivefilename(sourceitem, "pdf", "-", "") to {target_name, target_HFSpath}
set the name of the target_item to target_name
set the new_item to (move item target_name of the temp_folder to container of the source_item)
end tell
return new_item as alias
end run
on derivefilename(thisitem, new_extension, increment_separator, target_folder)
-- A sub-routine used for deriving the name and path of a new file using the name of an existing file
-- Pass in file ref in alias format, the new name extension, an increment separator, and any target directory (in alias format)
-- Name and HFS path for new file are returned. The name is incremented if a file exists in the target location.
-- Pass a null string for the target directory to use the item's parent directory
-- Pass a null string for the new name extension to use the item's current name extension
tell application "Finder"
if target_folder is "" then
set the target_folder to the container of this_item
end if
set the file_name to the name of this_item
set file_extension to the name extension of this_item
if the file_extension is "" then
set the trimmed_name to the file_name
set extension_separator to " (encrypted)"
else
set the trimmed_name to text 1 thru -((length of file_extension) + 2) of the file_name
set extension_separator to " (encrypted)."
end if
if the new_extension is "" then
set target_name to file_name
set target_extension to file_extension
else
set target_extension to new_extension
set target_name to (the trimmed_name & extension_separator & target_extension) as Unicode text
end if
if (exists document file target_name of target_folder) then
set the name_increment to 1
repeat
set the new_name to (the trimmed_name & increment_separator & (name_increment as Unicode text) & extension_separator & target_extension) as Unicode text
if not (exists document file new_name of the target_folder) then
set the target_HFSpath to ((target_folder as Unicode text) & new_name)
return {new_name, target_HFSpath}
else
set the name_increment to the name_increment + 1
end if
end repeat
else
set the target_HFSpath to ((target_folder as Unicode text) & target_name)
return {target_name, target_HFSpath}
end if
end tell
end derive_filename
This is the workflow - I use Automator because I need that Encrypt PDF action, I can't find any other way of doing it:
http://bit.ly/fzhbyU
Can anyone help ??
Message was edited by: brantwinter

It's not entirely clear what your issue is.
It sounds like your first script is returning:
"{alias \"Macintosh HD:Support:test-28 (encrypted).pdf\"}"
which is pretty easy to follow... you have a list containing one item, and that item is an alias (pointer to a file).
What's probably confusing you is the fact that you have a list, but that's because Automator always passes lists as the parameters, so the first thing to do is extract the alias from the list:
set my_file to item 1 of input
which will result in:
alias "Macintosh HD:Support:test-28 (encrypted).pdf"
so now you have a working file reference. If you want the POSIX form of that path, just ask for it:
set posix_path to quoted form of POSIX path of my_file
--> '/Support/test-28 (encrypted).pdf'
(note that I used 'quoted form of' since you have spaces (and, potentially, other non-shell safe characters) in the path.)

Similar Messages

  • Cross-reference between structured and unstructured FM documents

    Hello,
    Is it possible to retain FM cross-references from structured to unstructured FM documents during an XML round trip?
    From what I know, cross-references between or inside structured documents form pairs of ID and IDREF, while cross-references to unstructured documents are dumped as normal text and lose their functionality.
    The unstructured target documents might be converted to Structured FM at some point, but for the time being I'd like to find another solution. Do you know any solution to this?
    Thanks,
    Johannes

    Johannes,
    This is just a guess, because I do not do this.
    First, of course, you cannot export the unstructured file to XML, because it is unstructured.
    Second, IF the cross-reference from the structured file to the unstructured file were done via your cross-reference ELEMENT, then the cross-reference element should export to XML as an XML element with one of its IDref attribute set to the ID of something in the unstructured file. When you open the XML file in FrameMaker, the cross-reference is re-established.
    In other words, when exporting to XML, FrameMaker does not care to what you are referencing. It just converts the cross-reference element into an element with an attribute in the XML file. So, it should work as expected when opened in FrameMaker. Of course, I am assuming your read-write file is set up to handle cross-references.
    On the other hand, IF you are creating your cross-reference from the structured file by simply inserting a cross-reference, that is NOT as an element, then I do not know what happens. If it is being exported as text, then I am not sure FrameMaker will know what to do with it when you reopen the XML file.
    Hope this helps,
    Van

  • Passing session data between jsp and servlet

    I have a servlet that I pass data to my jsp.
    I do a session.setAtrribute in the servlet. No problem.
    I get the data no problem in the jsp that I call.
    How do I pass this same data to the another servlet?
    I basically have an array of values that I already have in the existing jsp that has been set in session.
    When I call the secondary servlet, I don't have anything in this session variable related to my array.
    Prior to posting to my next servlet, do I need to do another setAttribute inside the jsp to get the data passed to the servlet?
    Thanks.

    Two different things. The encoding adds this to the URL (after the page, before the query string
    ;jsessionid=ABC123 but only if the user isn't using cookies.
    So in your example, you would do this (maybe):
    <%
      String url = response.encodeURL("Servlet");
    %>
      <form name="form1" method="post" action="<%= url %>?cmd=pay"> ... Or some modification.
    So the difference between encodeing and using a post is that
    1) encoding adds the jsessionid to the url string if necessary. It does nothing else
    2) POSTing will send a request to the provided URL via the POST method, including the inputs of the form as parameters to the URL.
    They really don't interact with each other. It is like asking what is the difference between the Color Orange and thr Size Big? They can both be applied to the same thing, or not... and have no real relation to each other.

  • Pass parameter values between BEX and exctractor

    Hi All,
    I create virtual cube which report from ECC
    I create Extractor Transformation and DTP which load the data from ECC
    In the BEX I create parameter (Week day) which can get few values (E.g. 1,3,5)
    In the extractor I define field for week day and need to consider the week days parameter
    My question is how I pass the value between the BEX and extractor?
    Thanks in advance
    Itzik

    Hi Itzik,
    One simple solution,
    Create a new IOB with Texts. In the Variable exit, write the variable values to this text IOB using FM RSNDI_MD_TEXTS_UPDATE.
    Read the values from the IOB text using routine while selection.
    Sankar Kumar

  • Database table/FM to find relation between plant and company code in SRM

    Hi,
    I have a requirement where I need to determine the relation between the plant and company code in SRM.
    The plant and company code both belong to R/3. We are replicating the plant by using the report BBP_LOCATIONS_GET_ALL.
    This plant is now available as a BP in SRM. But from which SRM table or using which SRM FM can I get the relation between this and the company code?
    Thanks,
    Srivatsan

    Hi
    <b>Check table BBP_LOCMAP. (Plants) -  Manage Table Business Partner   > System   > Location
    BBP_COMPCODE_FAV               User-Specific Favorites for Permitted Company code.</b>
    Hope this will help.
    Please reward suitable points, incase it suits your requirements.
    Regards
    - Atul

  • Automator and applescript to copy new files in a folder with same name as parent folder

    I have an iMac with a pictures folder (Finder folder) containing several subfolders with pictures. As per now, all these subfolders are imported into an iPhoto library (and the structure of the Finder pictures folder is thus maintained: The iPhoto events are named the same as the Finder subfolder). I.e. I have not created any albums in iPhoto.
    I have also set up a workflow, where new iPhone photos are automatically being synced to specified Finder folders within the iMac pictures folder. So what I want to do is to make a workflow to import potential new photos from week to week into the existing iPhoto structure. I know iPhoto has this Autoimport folder, so this one is unpacked and "mapped". So, this is what I´m hoping to do:
    Automator (iCal - want to do this on a weekly basis):
    - Get specified Finder items -- set to target folder = iMac pictures folder
    - Get folder content (with subfolders)
    - Filter Finder items
         - Items from the last 7 days (which then would be any new files created last week)
    - Applescript/shell script loop(?)
         - Get folder name for each file´s (from previous step) parent folder
         - Create new folder with same name as the file´s parent folder (if not already existing) under the iPhoto Autoimport folder
         - Copy the given file into the folder from above
    - Run iPhoto application (Automator task), which then should just auto import the new photos according to the Finder folder structure
    Whith the workflow above, I aim to maintain the existing iPhoto structure, and just import new photos into the existing structure. Creating folder names under the Autoimport, similar as the existing Finder folder names / iPhoto events should make it possible to have the new files imported under the existing event, right?

    Anyone?
    I have now switched to Aperture (from iPhoto) due to Aperture´s capability to handle Finder folder structure, and due to the possibility of having the pictures within Aperture as referenced files to the pictures within the Finder folders (i.e. possibility to delete pictures from both library and Finder folder at the same time).
    So I have a superior Finder folder called "Album". Within "Album" I have several subfolders (sub albums) containing pictures. The "Album" folder with subfolders are imported into Aperture as "Projects and albums", and the pictures are uploaded within the Aperture structure as referenced files. So for now the Aperture structure is more or less a direct mirror of the Finder folder structure, whereas "Album" is the project.
    And this is my current workflow in Automator, but I´m searching help with my Applescript:
    - Get specified Finder items (target folder = the superior Finder folder "Album")
    - Get Folder content
    - Filter Finder items (to look for potential new files to import into Aperture)
         - Kind is not folder
         - Date created last X days
    The output files from this task enters an Applescript
    on run {input, parameters}
           repeat with f in input (**Loop**)
                   tell application "Finder"
                          set fileName to name of (f)
                          set parentFolder to name of container of (f)
                          tell application "Aperture"
                                 tell library 1
                                        tell project "Album"
                                               if (exists album parentFolder) then
                                                 ** I then would like to check if fileName already exist within the existing album**
                                                 ** If not existing, I would like to import file f into the existing album as a referenced file**              
                                               else if not (exists album parentFolder) then
                                                       make new album with properties {name:parentFolder}
                                                ** I then would like to import file f into the new album as a referenced file**
                                               end if
                                        end tell
                                 end tell
                          end tell
                   end tell
           end repeat
    end run

  • WSRP - Pass Custom Data between Consumer and Producer

    Hello All,
    I am having a couple of queries with respect to Custom Data Transfer. Consider I have a Map of values which I need to transfer between both Consumer and Producer.
    For eg: the map that Consumer sends would contain "firstName", "lastName", etc... On the other hand Producer needs to do some business function based on the data and add more values to the map like "rewardPoint" etc....
    On Consumer Side:
    I have choice to use Backing File or IGetMarkupInterceptor to implement the preInvoke to pass the data using SimpleStateHolder.
    Question: I am not able to send a simple Serializable POJO Object... I can only send primitive / default java objects like Strings, Maps of String etc. Is my understanding correct?
    On Producer side:
    I am able to receive the Custom Data from request. No problems. Now how to send more data from Producer to consumer. I need to add the "rewardPoints" into the map and send back.
    My understanding is that if the Producer puts any values into StateHolder objects, Consumer will receive it in IGetMarkupResponseContext object in the Interceptor's postInvoke method.
    Question: How do I get a handle to the IGetMarkupResponseContext object @ Producer end???
    Question: Do I need to write some interceptors on Producer end? If so which file I need to use?
    Any help / pointers would be greatly appreciated.
    Thanks,
    Paz

    Hi All,
    I tried to set the data in the producer using the following command
    SimpleStateHolder stateSimpleOuterReq = (SimpleStateHolder)request.getAttribute(MarkupRequestState.KEY);;
              if (stateSimpleOuterReq == null) {
                   SimpleStateHolder state = new SimpleStateHolder();
                   state.addParameter("name", "data1");
                   request.setAttribute(MarkupResponseState.KEY, state);
    I am not able to retrieve the same in consumer.
    The above is a WSRP struts request.
    I also tried setting the data by unwrapping the request in producer and still value is null in consumer :-(
              HttpServletRequest requestq = (HttpServletRequest)((HttpServletRequestWrapper) request).getRequest();
              SimpleStateHolder stateSimpleReq1 = (SimpleStateHolder)requestq.getAttribute(MarkupRequestState.KEY);
                   if (stateSimpleReq1 == null) {
                        SimpleStateHolder state = new SimpleStateHolder();
    state.addParameter("name", "data1");
                        requestq.setAttribute(MarkupRequestState.KEY, state);
    Please help me in resolving the issue. Correct me if i am doing anything wrong.
    Thanks
    T. Deena
    Edited by: user11261911 on 12/06/2009 19:49

  • Using Automator and Applescript to search and move files to flash drive

    I've used applescript and automator to do simple tasks like watch folders and move files and rename files, but that is about the extent. I am wondering if it is possible to set up a automator service or app that will do several things.
    When a flash drive is plugged it, it will ask for a file to be searched for, then it will search a predetermined directory for files with the word or number in them and then it will copy the found files to the mounted flash drive.
    Any help would be greatly appriciated!
    Thanks!

    As a start, you can use launchd to run a script when a volume is mounted:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
              <key>Label</key>
              <string>com.tonyt.LaunchOnVolMount</string>
              <key>ProgramArguments</key>
              <array>
                        <string>LaunchOnVolMount.sh</string>
              </array>
              <key>QueueDirectories</key>
              <array/>
              <key>StartOnMount</key>
              <true/>
              <key>WatchPaths</key>
              <array/>
    </dict>
    </plist>
    You can then have the LaunchOnVolMount.sh script perform the tasks you need.
    You can incorporate Applescript within the Bash script with osascript:
    #!/bin/bash
    answer=$( osascript -e 'tell app "System Events" to display dialog "What file do you want to search for?" default answer "" ' )
    echo $answer
    I beleive that you can also call an Applescript from launchd

  • Automator and Applescript to export movie with quicktime

    I have started a work flow that asks for some files from a folder and then passes the list to an Applescript. So far the script is:
    on run {input, parameters}
    set output_items to {}
    tell application "QuickTime Player"
    activate
    close every window
    end tell
    repeat with i in input
    tell application "QuickTime Player"
    open (i as alias)
    -- HERE HERE HERE
    close front document
    end tell
    end repeat
    return output_items
    end run
    What I cannot figure out is how to get the file name excluding the extension where I have "HERE HERE HERE". I want to be able to get Quicktime to export the file to the desktop with the same file name as a Quicktime Movie. I cannot figure out how to do this...any help?

    Thanks to both of you for your help.
    I have made (well still in the process of finishing it up) a folder action work flow that takes movie files, converts them to an iPhone format and moves them to iTunes.
    I would like to give credit where credit is due. If you guys are okay with it, can I add your info (name, email, profile on apple discussions, whatever) to the credits?
    Thanks
    _Nacho

  • Extract the references between BS and PS and other PS

    Hi everybody,
    I would like to know if is possible to extract the relations (referenced by and references) about all the PS and BS in the OSB 11g.
    I would like to do a map about all the services deployed in the OSB and his relations between them.

    Have you noticed that the data types for these two fileds are different thought the field desc is the same?
    POSID is for WBS elemnt in ext format while PS_PSP_PNR has the internal format. Double click on the Data elements  of these fields in SE11 & you can see the Conversion routines tied to them.
    ~Suresh

  • Find Conflicts between start and end time

    I have a table appointment (appointment_id, start, end ,  Location) will hundreds of records like below
    appointment_id        start                                                    
    end                                            Location
    1                            2015-04-29 10:00:00.000              2015-04-29 12:00:00.000            
             ABC
    2                            2015-03-29 09:00:00.000         2015-03-29 13:00:00.000             
    XYZ
    3                           2015-03-29 10:00:00.000         2015-03-29 11:00:00.000             
    XYZ
    if you see appointment id 2 and 3 they are conflicting with same location
    appointment id2 starts at 9 am and ends at 1pm ,
    but appointment id3 also reserved  same day & same location start at 10am and ends at 11 am ..
    this should not be possible ....
    can you help in finding how many such conflicts are there in the  appointment table ?
    i will have to find a report...
    Thanks

    Hi coolguy123SQL,
    Regarding your description, does the appointments happened in the same prefixed locations with a time span overlap mean a conflict? If my understanding is correct, you may reference the below code.
    DECLARE @myTable TABLE (appointment_id INT, startDateTime DATETIME, endDateTime DATETIME, location VARCHAR(10))
    INSERT INTO @myTable
    SELECT 1, '2015-04-29 10:00:00.000', '2015-04-29 12:00:00.000', 'ABC' UNION ALL
    SELECT 2, '2015-03-29 09:00:00.000', '2015-03-29 09:30:00.000', 'XYZ-123' UNION ALL
    SELECT 3, '2015-03-29 10:00:00.000', '2015-03-29 11:00:00.000', 'XYZ-456' UNION ALL
    SELECT 4, '2015-03-29 11:00:00.000', '2015-03-29 13:00:00.000', 'XYZ-789'
    ;WITH CTE AS
    SELECT appointment_id,startDateTime,endDateTime,location,
    CASE WHEN CHARINDEX('-',location)=0 THEN location ELSE SUBSTRING(location,1,CHARINDEX('-',location)-1) END AS locationID FROM @myTable
    CTE2 AS
    SELECT *, ROW_NUMBER() OVER(PARTITION BY locationID ORDER BY startDateTime) AS seq FROM CTE
    SELECT
    c.appointment_id conflict_appmt_id1,c.startDateTime startDateTime1,c.endDateTime endDateTime1,c.location location1,
    t.appointment_id conflict_appmt_id2,t.startDateTime startDateTime2,t.endDateTime endDateTime2,t.location location2
    FROM CTE2 c JOIN CTE2 t ON c.locationID=t.locationID and c.endDateTime>=t.startDateTime AND c.seq<t.seq
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Please help me  to find link between customer and Business partner

    Hi All,
    With the help of customer number as input for my report, i have to find the Business partner.
    Please help me how  to find the Business partner based on the customer number using tables.

    hi,
    Get the customer address number from the KNA1 table
    and pass that to the FM ADDR_GET with address group as BP( business partner)
    you get the Business partner address number and from that you can find the business partner number from KNA1 table
    or in KNVP table field KUNN2 gives the BP number
      DATA: w_selection_ds     TYPE  addr1_sel,
            w_addrprnt_ds      TYPE  adrs_print,
            w_adrs1_ds         TYPE  adrs1.
      clear w_address_value_ds.
      w_selection_ds-addrnumber = w_kna1_ds-adrnr.  "address number
      CALL FUNCTION 'ADDR_GET'
        EXPORTING
          address_selection = w_selection_ds
          address_group     = 'BP'         "business partner
        IMPORTING
          address_value     = w_address_value_ds
        EXCEPTIONS
          address_not_exist = 1
          OTHERS            = 2.
    regards
    Prasanth

  • Total newbie to Automator and Applescripts needs advice.

    Hi All,
    I've read about all these great little apps that can do repetitive things for me. I can't wait to get started. I downloaded an applescript and, well, now what? What do I need to do to get it to run? It's an app that will quit all MS apps before backing up (that will prevent my MS database from getting corrupted, can't have that)--I want it to run on its own before my backup software kicks in.
    Thanks.

    May I suggest that you begin with the following links (in the specified order):
    1. [AppleScript: The Language of Automation|http://www.macosxautomation.com/applescript>
    2. [Beginner’s Tutorial: The First Step|http://www.macosxautomation.com/applescript/firsttutorial/index.html]
    3. [Essential Sub-routines: Overview|http://www.macosxautomation.com/applescript/sbrt/index.html]
    4. [AppleScript Language Guide|http://developer.apple.com/mac/library/documentation/AppleScript/Conceptu al/AppleScriptLangGuide/introduction/ASLRintro.html#//appleref/doc/uid/TP40000983-CH208-SW1]

  • Which table where I can find diff between Invoice and subseq deb/ cred

    Dears,
    Is ther any table from where I can check whether Invoices is created based on
    1, Invoice
    2. Subsequent debit/Credit.
    I could not find the difference in rbkp table. Pls suggest
    Regards
    Kamesh

    Hi,
    Invoice Header table: RBKP
    Invoice item table: RSEG
    and check following link also
    [How to identify an invoice/credit memo/ subs credit / subs debit in tables;
    Regards
    Kailas Ugale

  • How can I pass a variable between JSP and Role Form

    I need to pass a variable from (a copy of) applicationmodify.jsp to the IDM Role Form so that the variable is available within the Role Form at display. We've tried getAttribute and setAttribute modifying both the Role Form and the applicationmodify JSP and can get the form to the role form but not accessible but have had no other success. Has anyone had any success in doing this? Any suggestions would be appreciated.

    if by _root level you mean you're loading something into
    _level0 you can't won't be able to use the localconnection. the
    sharedobject is your only option.

Maybe you are looking for

  • Image processor option missing from bridge cc

    In the past I have been able to open Bridge and go to tools - photoshop- image processor and then a panel would open where I could resize my images, change their file type, and apply an action to a batch of photos. I just updated my version of Bridge

  • Table with bith dynamic and non dynamic data

    Hi all, We have a report already developed. Now we need  add some fields from some table which is dynamic in feature to the final report which is already there. I need to know how come we can include the dynamic fields into the final internal table.

  • What workstation is used the most?

    I am switching from Web Premium CS3 to Master Collection CS5 which means that I am moving from Sony Movie Studio to Adobe's movie/video creation software.  I know I need to upgrade my computer which is now 4 years old. Does anyone have suggestions ab

  • 2014 MBP: 1 x 4k display & 2 x 1k Displays, possible???

    Hi, Today i have two Full HD displays running through Thunderbolt and HDMI. Is it possible to connect a third display (4K at 60Hz) through the remaining Thunderbolt display?? I'm aware of the limitations of running only one 4K at 60hz through the Mac

  • Nvida driver - can't find nvidia module

    Finally went out and bought an nvidia geforce 6600Gt video card. But guess what now I can't install the dam thing. I followed the arch wiki but all I get is Installation starts now ... FATAL: Module nvidia not found. If you need more information abou