Help to create simple Applescript

Hi, hopefully somebody will be able to help me with a simple Applescript.
I want to be able to drag a pdf file onto a desktop icon, enter a new filename into a dialogue box and for the file to be copied to a specific folder. It will only be pdf files, and I want it to automatically append the .pdf extension.
Could sombody possibly point me in the right direction? Thanks in advance.

Oops, forgot one more check. If a file exists with the same name as the original file, then it will error when you duplicate it. One way to solve that is to duplicate in place. Then "copy" is added to the name. You then move the file to the destination folder and probably there is no file with "copy" in its name.
property folder_location : (path to desktop)
property folder_name : "Files"
on open these_items
-- added check for main folder
tell application "Finder"
try
set main_folder to (folder folder_name of folder_location) as alias
on error
set main_folder to (make new folder at folder_location with properties ¬
{name:folder_name})
end try
end tell
repeat with this_item in these_items
set n to name of (info for this_item)
if n ends with ".pdf" then
set temp_prompt to "Enter a name for duplicate of " & n & ":"
repeat
display dialog temp_prompt default answer "name"
set new_name to (text returned of result) & ".pdf"
tell application "Finder"
if not (exists file new_name of main_folder) then
set the_duplicate to (duplicate this_item) as alias
move the_duplicate to main_folder
set name of the_duplicate to new_name
exit repeat
else -- inform user to enter a different name
set temp_prompt to "Enter a different name. The name " & new_name & " is used."
end if
end tell
end repeat
end if
end repeat
end open
Otherwise, What I usually do is create a empty temp folder for doing renaming, but then it gets more complicated. For now, just don't use "copy" in names.
gl,

Similar Messages

  • Help with a simple applescript for combining Artist text with Track name

    Hi all,
    I'd like to put together a simple script that takes the artist names from a list of tracks in iTunes and copies the text to the start of the Title name, followed by " - ".
    This is because, e.g. on a classical album, I want the artist names to all be "Classic Collection Gold" but I'd like to keep the artist name contained with the track name. This means when I browse by artist I don't get millions of artists...
    I found this script, which does something kinda similar, but I'm new to script writing so not sure how to do it?
    So I'd like to change:
    Name
    Planets: Mars
    Artist
    Gustav Holst
    Ambum:
    Simply Classical Gold (Disc 2)
    To be:
    Gustav Holst - Planets: Mars
    Artist
    Gustav Holst - Planets: Mars OR BETTER Simply Classical Gold (Disc 2)
    Album
    Simply Classical Gold (Disc 2)
    This script has some ideas in, but I'm not sure how to tweak it....
    "Artist - Name Corrector" for iTunes
    written by Doug Adams
    [email protected]
    v1.6 May 17, 2004
    -- removed ref to selection
    v1.5 April 11 2004
    checks if separator string is in name
    v1.0 April 2 2004
    Get more free AppleScripts and info on writing your own
    at Doug's AppleScripts for iTunes
    http://www.malcolmadams.com/itunes/
    property separator : " - "
    tell application "iTunes"
    if selection is not {} then
    set sel to selection
    repeat with aTrack in sel
    tell aTrack
    if (get name) contains separator then
    set {artist, name} to my texttolist(get name, separator)
    end if
    end tell
    end repeat
    end if
    end tell
    -- == == == == == == == == == == == == == == == ==
    on texttolist(txt, delim)
    set saveD to AppleScript's text item delimiters
    try
    set AppleScript's text item delimiters to {delim}
    set theList to every text item of txt
    on error errStr number errNum
    set AppleScript's text item delimiters to saveD
    error errStr number errNum
    end try
    set AppleScript's text item delimiters to saveD
    return (theList)
    end texttolist
    Message was edited by: Chipstix

    I'm not sure what that script thinks it's doing, but it's essentially doing nothing, so scrub that and start afresh.
    The first thing you need is a way to identify the tracks to change - you don't want to do all tracks in the library (they might have already been munged). A good option is to work on the selected tracks:
    tell application "iTunes"
    if selection is not {} then
    set sel to selection
    You then need to iterate through those items, changing them one-by-one:
    repeat with aTrack in sel
    Now comes the easy part - build a list of the elements you want (in this case you want the name, artist, and album of each track:
    set trackName to name of aTrack
    set trackArtist to artist of aTrack
    set trackAlbum to album of aTrack
    Now you have the information you need, so reset the fields as appropriate:
    set name of aTrack to trackArtist & " - " & trackName
    set artist of aTrack to trackAlbum -- or to trackArtist & " - " & trackName, depending on your choice
    Now clean up by closing off the repeat and tell blocks:
    end repeat
    end tell
    Putting it all together you get:
    tell application "iTunes"
      if selection is not {} then
      set sel to selection
      repeat with aTrack in sel
        set trackName to name of aTrack
        set trackArtist to artist of aTrack
        set trackAlbum to album of aTrack
        set name of aTrack to trackArtist & " - " & trackName
        set artist of aTrack to trackAlbum -- or to trackArtist & " - " & trackName, depending on your choice
      end repeat
    end tell

  • Help me! - Simple Applescript to make a word doc center all contents

    Hello!
    I am working on a small applescript which I will be using in Automator, however I can't for the life of me figure out how to script in telling the word doc to automatically center everything (text and images).
    I have the following applescript which sets up the word doc in the margins and orientation I need, but now I just need to figure out how to center the contents.
        tell application "Microsoft Word"
                        set orientation of page setup of section 1 of active document to orient landscape
                        set pmRpt to page setup of active document
                        set left margin of pmRpt to (inches to points inches 0.85)
                        set right margin of pmRpt to (inches to points inches 0.95)
                        set top margin of pmRpt to (inches to points inches 1.5)
                        set bottom margin of pmRpt to (inches to points inches 1)
              end tell
    Can anyone help me?
    Thanks!!!

    Hi,
    Like this :
    set alignment of paragraphs of active document to align paragraph center

  • Help in creating simple statefull EJB program

    Hello , i m new to EJB and right now i m developing statefull ejb application. I have created stateless ejb application and it was working well but now facing some problem with maintaining state in statefull ejb application.
    Here i m simply developing one counter application ... what i have done is as below ....
    ============================ CounterBean ================
    package ejb;
    import javax.annotation.PostConstruct;
    import javax.ejb.Stateful;
    @Stateful (mappedName="ejb/CounterBean")
    public class CounterBean implements CounterBeanRemote {
    private int _count;
    @PostConstruct
    public void initialize()
    _count = 0;
    public int increment() {
    _count++;
    return _count;
    =================Remote interface for CounterBean==========================
    package ejb;
    import javax.ejb.Remote;
    @Remote
    public interface CounterBeanRemote {
    public int increment();
    =========================index.jsp===================jsp page to get result from ejb ========
    <%@page contentType="text/html" pageEncoding="UTF-8" import="ejb.CounterBeanRemote,javax.naming.InitialContext"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%!
    CounterBeanRemote _CBR = null;
    %>
    <%
    InitialContext _IC = new InitialContext();
    CBR = (CounterBeanRemote) IC.lookup("ejb/CounterBean");
    out.println(_CBR.increment());
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
    <body>
    <h1>Hello World!</h1>
    </body>
    </html>
    ===============================================================
    so, here every time i refresh my page counter should be increase as i m using statefull bean ...
    but its not happening ....
    every time i refresh page, all time result coming is only 1 ... its not incrementing .... can any one tell me what i m doing wrong ..... i m not able to maintain state ....
    thnks .... please reply ....

    The issue is not where to put the lookup code. The issue is that each call to InitialContext.lookup() produces a new Stateful session bean instance. It's the reference that is returned from lookup() that represents the interaction with a particular client. You'll need to store that reference somewhere across the multiple client interactions in order to maintain the statefulness you're looking for. Typically, that means storing it within the HttpSession.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Need Help to create new screen for RF Sapconsole

    Hi Guru's
    I'm new on RF (but some years in ABAP) since last week.
    I need help to create new screens for RF (SAPLLMOB).
    Can someone explain me the procedure to create screen (with ABAP code after) or perhaps someone have an exemple (simple or not) ?
    I have to develop 2 new screens with really few time.
    And, another subsidiary question :
    how SAP can transfert information between the flash gun and the screen i have developped.
    Is there some code to add to enable this functionality or it is include in SAPLLMOB on standard fields ????
    It's a new strange world for me today...
    Many thanks to everyone who can explain me
    Alain

    hi,
    I am facing this problem as well. Is there any reference to create the new screen?
    Hope someone can help! Thanks!
    Regards,
    Darren

  • Need help to create report with jpeg/gif image

    Hello,
    I need help with creating a form with a special jpeg/gif seal. I never done this Java. Until now, I created all forms with ansi C++ with HP escape characters to draw lines, boxs, and text. This form will contain boxes which is populated with database information read from a text file.
    Since this form contains a special seal on the upper right, I don't think it can be done with old fashion ansi C++. How can I create a form with Java and create it as a simple exe to just print the form to a specified printer.
    Thanks,
    John

    Hi,
    I am creating a form with boxes (lines and text). What is special about this form is that it has an image jpeg or gif at the top right corner. Is is a state department seal. Up to this form, I had used ansi C++ and print out escape HP character to print out the lines, boxes, and text. I have no idea how to print out the image. I am new to JAVA and only 1 class in it. Is there sample code out there to create this type of form with the image? I need a starting point.
    Thanks,
    John

  • Need help in creating RAID 5

    Hi everyone,
    i'm fairly new to RAID scene and i need help for creating RAID 5 with 8 disk's. 
    I have HP ProLiant DL380 G6 with 8 disk's, each 500 GB.
    i'm trying to create RAID 5 and to have one spare disk. I have made array from 7 disk and then create logical drive.
    the last disk (8-th) i used as spare. 
    up to now i think i'm ok???
    what confuse me is:
    7 HDD X 500GB= 3500GB
    after creating array i get 3200 GB, where i lose 300 GB??
    after creating logical drive i get 2700 GB, where i lose 500 GB???
    from 2700GB i give 150GB for system partition and for data storage i have only 2550 GB.
    Why i lose 800GB??
    Can someone explain me how RAID 5 works, do i create it correctly and why i lose so much space???
    Is there other way to create RAID 5 without losing so much space? 
    Thanks you in advnce. 

    The first 'loss' you encounter (300MB) is due to megabyte counting/rounding.  A 500GB disk contains about 500.000.000 bytes. This quite a bit less than if counted properly using binary. you loose about 24288000 bytes per disk this way!
    http://en.wikipedia.org/wiki/Mibibyte |
    http://en.wikipedia.org/wiki/Megabyte
    the second loss is due to how raid works.in raid 5 data is written to multiple disks to improve reliability. the simplies t form uses 3 disks: a write will cause half of the data to be written to disk 1, half to disk 2 and the XOR of both datahalfs to disk
    3. In this scenario you will loose 33% of storage space and you can loose up to one of 3 disks.
    By adding more disks, data can be spread more and the ratio available/raw will increase, or you can write aditionnal crc data and increase resliency for failures.
    http://en.wikipedia.org/wiki/RAID
    To check the exact algoritmes using on you RAID adapter, I would recommend contacting the vendor (or checking their support site) From your numbres, I do not think you will be able to configure RAID 5 on the same disks and having more available
    space for your data.
    MCP/MCSA/MCTS/MCITP

  • "Create Simple document" from other objects

    Scenario: Creating a document using option "Create Simple document" from other objects
    I have created a document type and defined the object link for Functional Location with option "create simple document"
    When clicking on create icon on the additional data tab on IL02 screen, The system asks for the document type and then the file to be uploaded.
    The document type that i have defined has the Description filed as mandatory field and hence i am not able to create the document.
    However, for the Document type when i set the description field as not mandatory the system creates DIR. But this DIR has no description.
    Please let me know if there is a BADI, using which i could set the Functional location name as the description OR if there is some enhancement by which the user is asked to enter the description when creating the document.
    Warm Regards,
    Vivek Mohankumar

    Hi Vivek,
    After my tests I would like to inform you that this is                  
    the standard system behavior as the document description field is       
    maintained as mandatory in transaction DC10. Please note that for the   
    simple creation of documents this should not be set as a mandatory      
    field.                                                                               
    The creation mode can be defined in transaction DC10 for each object    
    under 'Define object links'.                                                                               
    Please note that the value "1" for the creation of documents is used    
    to enable a user to simple attache a word file to an object             
    without going to the transaction CV01n. Therefore the system behaviour  
    is different then creating a document by CV01n and attaching a          
    file to it. With simple creation mode there should not be any           
    mandatory fields as the user cannot enter anything during the creation  
    process.                                                                               
    However, you can change the behaviour how the document is created by    
    MM02 transaction if you change the customizing in transaction DC10      
    like this:                                                                               
    If you maintain the value "2" for creation of documents, the user is    
    put to transaction CV01n and then the description can be entered. So    
    maybe this would solve the issue.  
    Regarding a useful BADI I can only recommned you to test BADI DOCUMENT_OBJ1,
    DOCUMENT_OBJ2 or DOCUMENT_MAIN01 for fill the description field.
    I hope this information could be useful for you and help to avoid the   
    mentioned error message.                                                                               
    Best regards,
    Christoph

  • Help populating table with applescript

    Hi
    I'm posting here in the hope that someone can give me a helping hand with an applescript. I myself know very little about applescript. I can create something very basic but thats about it.
    I have the following table
    Name
    Value
    Amount
    Donald Duck
    4
    5000
    Goofy
    10a
    7000
    George
    5
    4000
    Steve
    4
    6000
    Hank
    18
    9000
    Sue-Ellen
    5
    9050
    John
    18
    11000
    Hector
    18
    5500
    I would like to create an applescript that runs through this table and populates another table, we can call it "Results", that would look something like this
    Value 4
    Donald Duck
    5000
    Steve
    6000
    Value 5
    George
    4000
    Sue-Ellen
    9050
    A further complication is that this newly populated should only be populated if the following condition exists. The total sum of the newly created table (i.e the value column) should only be populated with posts from the original table as long as the sum of the newly created posts do not exceed the sum of a cell in a third table (we can call this the "sumtable").
    To make it clearer. If the sum of the "sumtable" is 24 050 then the newly created table will only create the posts I have made above. These posts must be made using the following values and in the order the values appear. The complete list of values is 3a, 4, 4a, 5, 6, 7, 10, 10a, 12, 13, 18 . So the script would start looking for values in that order and whenever it reaches a total sum that is equal to the sum in "sumtable" it will use those values, and only those, and populate the new table creating the necessary rows needed.
    It's possible that this is way to complicated to do. I have tried to make a formula in a table to do this but the problem is I ca never know how many rows are needed in advance.
    Hoping for some help or tips, but understanding if this is asking too much considering the amoutn of effort needed.
    Thanks

    consiglieri_swe wrote:
    i.e Goofy only gets part of his debt.
    The partial payment complicates the logic a little. Below is a script that can handle that. The usage is the same. Paste it into AppleScript Editor. Run. Paste results into A2 of the Results table and the table expands automatically to the number of rows needed. The Sum formula is in a Footer Row.
    The revised script, which now reads the available amount from a cell in a table (easily changed to another table as needed), is below.
    SG
    --accounts for partial payment of "last" creditor
    --reads available amount from a cell in a table
    property thePriorities : {"3a", "4", "4a", "5", "6", "7", "10", "10a", "12", "13", "18"}
    tell application "Numbers" to tell the front document to tell sheet "Sheet 1"
              tell table "Maximum"
                        set maxAmount to the value of cell "A2"
              end tell
              tell table "Table 1"
                        set {pasteStr, stillAvailable, allDone} to {"", maxAmount, false}
                        repeat with i from 1 to count of thePriorities --cycle through 3a, 4, 4a, etc
                                  set priorityBeingTallied to (item i of thePriorities)
                                  repeat with j from 2 to count of its rows
                                            tell row j
                                                   --get the values in a row
                                                      set thisName to value of its first cell
                                                      set thisPriority to my stripDecimal(value of its second cell)
                                                      set thisAmount to value of its third cell
                                                      if thisPriority is equal to priorityBeingTallied then --if it's in this priority
                                                                if stillAvailable > 0 then --include the row unless no more money
                                                                          set thisAllocation to my lesserOf(thisAmount, stillAvailable)
                                                                          set pasteStr to pasteStr & thisPriority & tab & thisName & tab ¬
                                                                                    & thisAllocation & return
                                                                          set stillAvailable to stillAvailable - thisAllocation
                                                                end if
                                                      end if
                                            end tell
                                  end repeat --rows
                        end repeat --priorities
              end tell --table
    end tell --app
    set the clipboard to pasteStr
    display notification "Click once in a cell and paste." with title "Numbers"
    pasteStr
    --handler needed because when asked for a cell value Numbers 3 adds .0
    to stripDecimal(val)
              set val to val as string
              set {oTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "."}
              set s to item 1 of val's text items
              set AppleScript's text item delimiters to oTID
              return s
    end stripDecimal
    to lesserOf(x, y) --used to calculate partial payment to "last" creditor
              if x < y then return x
              return y
    end lesserOf
    --end of script

  • Help to create item at run time

    Hi all
    Please help to create item at run time
    I want to create item at run time
    is it Possible ???
    thank you

    Hi,
    As mentioned several times above, you cannot use Forms for displaying dynamic columns. So, you have two options (AFAIK).
    1. Create maximum number of items and set their visibility off based on the user input.
    2. Create a PJC (may be by extending JTable), and display dynamic columns (i feel it is a bit complicated and not straight forward as it sounds). Here is a [simple howto|http://sheikyerbouti.developpez.com/forms-pjc-bean/first-bean/first_bean.pdf] to build the PJC.
    -Arun

  • I'm trying to create an applescript to install printers - cant seem to get it to work

    So I'm running 10.7and I'm trying to create an applescript to install printers.  I'm able to run the first command without issues but the other two keeps giving me error messages in applescript.
    I assume its because the other two commands have spaces?
    These are the commands I run when in Terminal:
    /usr/sbin/lpadmin -p CX560 -E -v lpd://CX560/print -P /Library/Printers/PPDs/Contents/Resources/en.lproj/US-Letter/CX560_V1.PPD -D FireStationCX560
    /usr/sbin/lpadmin -p CX560-WORD -E -v lpd://CX560/print -P /Library/Printers/PPDs/Contents/Resources/en.lproj/Xerox\ Color\ EX\ 550-560 -D FireStationCX560-WORD
    /usr/sbin/lpadmin -p Firestation-HP5200 -E -v lpd://firestation-lj5200 -P /Library/Printers/PPDs/Contents/Resources/HP\ LaserJet\ 5200.gz -D Firestation-HP5200
    This is the only command I can successfully run in AppleScipt:
    do shell script "/usr/sbin/lpadmin -p CX560 -E -v lpd://CX560/print -P /Library/Printers/PPDs/Contents/Resources/en.lproj/US-Letter/CX560_V1.PPD -D FireStationCX560"
    Mind you this is the first time I'm trying this out so please be patient.
    Thanks!

    First things, when you post about a script and/or any errors you are getting it is a good idea to include the scrtpt and the exact error message you are getting. Just makes it easier to try and help.
    You're right about the spaces being the problem. You need to double escape them. That is
    /usr/sbin/lpadmin -p CX560-WORD -E -v lpd://CX560/print -P /Library/Printers/PPDs/Contents/Resources/en.lproj/Xerox\\ Color\ EX\\ 550-560 -D FireStationCX560-WORD
    that should do it. If you;re still getting errors post bask with the error message.
    regards

  • Help with creating Automator Folder Action

    Hi
    I want to create a folder action to empty my Caches from my both System and User Library files. I want a little help in creating the workflow. I tried to create a workflow, but the problem is it was asking for the system password when I selected the Library cache folder from my System. How can I create a workflow and save it as a plugin for my everyday action...
    thanks in advance..

    HI,
    Not sure if Automator can do that but AppleScript might. Post here for help.
    (Applications/Utilities)
    http://discussions.apple.com/forum.jspa?forumID=724
    Carolyn

  • How do I create an applescript virus scanner?

    I was trying to create an Applescript antivirus scanner.  I'm just trying to get a basic concept of a scanner.  Not anything like Norton.

    You mean you're planning to write it in AppleScript? I don't know that that will work very well, though I'm far from an AppleScript expert.
    Writing a malware scanner is not an easy task. You would need some method of creating "signatures" that can match known malware, and then you would need to compare files being scanned against those signatures. Then, you would need malware samples from which to make those signatures. You would have to make sure to choose a signature that will match all variants of the malware but wouldn't match anything else, since false positives are bad.
    If your intent is to simply have fun and learn more about these techniques, then by all means, forge ahead! It will take a lot of work and research. I would recommend teaching your app to detect specific legit apps to start with, as collecting malware samples is not going to be easy initially. Only once you have started to demonstrate some expertise in the area and intent to help with "white hat" activities will anyone give you access to a malware database.
    One starting point for learning the basic idea behind signatures would be the YARA project:
    https://code.google.com/p/yara-project/
    If, on the other hand, your intent is to actually create a working, usable and realistic malware scanner... don't. Not to be discouraging, but that just won't turn out well. Your efforts would be better spent contributing to a project like ClamXav, where you could learn the skills and the market better, and could start a project later on with more experience and expertise under your belt.

  • How to create simple JSP and deploy to J2EE engine?

    Hi,
    I need to create simple JSP pages and deploy it to SAP J2EE engine.. what is the procedure?...I may later add some businness logic but not needed for now.
    Please help
    Thanks,
    Jai

    Gabrie,
    Here are Simple steps,
    In the NWDS
    1) create J2EE -> Web Module Project    (XYZ)
    2) create/add your JSP pages to the project
    3) Right click on your project root and click on 'Build Web Archive' from the context
    3) create J2EE -> Enterprise Application project(EAR)
    4) Right click on your Web Module Project root and click on 'Add to EAR Project' from the context, select the EAR you just created in step 3.
    5)Right click on your EAR project root and click on 'Build WebApplication Archive' from the context
    6)Expand the EAR project node, and right click on the *.ear file, click on 'Deploy to J2EE Engine'.
    7)Enter your SDM password  when prompted,
    You can access you JSP at this url
    http://server:port/xyz/a.jsp
    - Dileep

  • Converting simple AppleScript to JavaScript

    Hello to all,
    I need to convert a simple AppleScript to JavaScript, but as I don't know one bit about JavaScript, is there anyone willing to help me out ?
    Here is the AppleScript:
    tell application "Adobe Photoshop CS5"
         activate
              set display dialogs to never
              set thisdoc to current document
              tell thisdoc
                        resize image resolution 300 resample method none
              end tell
    end tell
    Very simple script to resize some low-res pictures without touching final resolution.
    Thanks !

    This will change the resolution only..
    app.displayDialogs = DialogModes.NO;
    activeDocument.resizeImage(undefined, undefined, 300, ResampleMethod.NONE);

Maybe you are looking for

  • Is the new macbook air any good for logic pro?

    hi. i currently have a heavy 15" macbook pro with i7 dual core 2.66GHz processors. i travel a lot and am really thinking about getting a macbook air. i want to know if any logic users are on the new 13" macbook air and how they find it. can it run la

  • FORCED DATA PACKAGE WITH PHONE UPGRADE

    I have been a verizon customer since cell phones were cool.  I started with a bag phone in my car.   I have 5 verizon phones.   Four on a family plan and one through a work plan.   My son wanted to upgrade his phone today which is eligible for early

  • How do I set Sync on my mac? It's running OS10.4 & Ff 3.6.22

    I've set up Sync on my Windows 7 PC and now I want to sync it with my Mac. The mac runs OS10.4 with Firefox 3.6.22 (being the latest available), but Firefox does not have the Sync option available in Options (Preferences, as it is on the Mac). So, ca

  • Awful service from infinity installation engineer

    We had our BT Infinity installation engineer visit today and are trully shocked and disgusted with the experience. I was working so my wife took the day off work for the engineer visit. The engineer was a SUB CONTRACTOR as we found out to our dismay.

  • Question about  Buttons in swing

    How i can have circular button in GUI program.