Quoted form of the POSIX path & drag n drop

Hi. I have the following situation: A part of a script-application that copies files over the network checks if there is actually enough disc space left on the target volume using the df and du commands.
This is how I do it:
on open (dragged_items)
my handleFiles(draggeditems)
end open
on handleFiles(theseitems)
set the item_sizecheck to the quoted form of the POSIX path of these_items
do shell script ("du -sk " & item_sizecheck & " | awk '{print $1}'")
set x to the result
set destination to "/Volumes/basti"
do shell script ("df -k " & destination & " | xargs echo | awk '{print $11}'")
set y to the result
if x ≤ y then
display dialog "space there"
end if
if x ≥ y then
display dialog "no space"
end if
end handle_Files
Of course in the orininal script instead of displaying a dialog that there is enough space the script will simply copy the files.
The problem now is that I can't get the "quoted form of the POSIX path" for many items at the same time (let's say I want to copy 3 things simultaniously).
So I think I have to cycle through the items (set this_item to item i of these_items),but then I have a problem:
I think checking the filesize/discsize is easiest done by the simple equasion (x larger than y),but if i do this for many objekts i have to use a unknown number of variables.
example:
x1 would be the first of the 3 items I draged onto my application,x2 is the second and x3 the third (...)
Then I would have to add up the filesizes of all these items using du,and then compare it to the available disc space ((x1x2x3) greater than y).
How do I do this?

>For what do I need the Applescript Text delimiters,what do they do?
Text Item Delimiters are used by AppleScript anytime to convert a list to/from a text object.
Imagine you have a list myList containing the strings {"A", "B", "C", "D"}
If you ask AppleScript to:
<pre class=command>set myString to myList as text</pre>
You get:
<pre class=command>ABCD</pre>
However, if you set the TIDs to a space first, AppleScript inserts that between each item in the list:
<pre class=command>set my text item delimiters to space
set myString to myList as text</pre>
Now you get:
<pre class=command>A B C D</pre>
You can use any text string you like - it'll be inserted between each item in the list as it's coerced (or, if you're going from a string to a list, the list items will be delimited by the TIDs).
It's relevant in this example because you're trying to pass multiple file paths to a shell command. The shell requires each argument to be delimited by a space. If you didn't set the TIDs you'd end up with a shell command that looks something like:
<pre class=command>du sk /path/to/file1/path/to/file2/path/to/file3</pre>
which the shell will interpret as a single path. By using a space for your TID you get:
<pre class=command>du sk /path/to/file1 /path/to/file2 /path/to/file3</pre>
which works (assuming the paths are valid, of course).
The one gotcha with setting TIDs is that they're persistent. If you change them at one point in your script, they stay until they're changed again. This often causes confusion when debugging scripts because the TIDs are set somewhere else in the script that you're not currently focussing on. So you should always get in the habit of storing the current TID, making your coercion, then resetting the TIDs to the previous value afterwards - that way you always know you're safe:
<pre class=command>set oldTIDs to my text item delimiters -- save the current TIDs
set my text item delimiters to space -- set the TIDs to what you want
set myString to myList as text -- make your coercion
set my text item delimiters to oldTIDS -- then restore the previous value</pre>

Similar Messages

  • How to get the POSIX path of a display profile under 10.6?

    Hi forum,
    I'm currently struggling with an AppleScript that returns the POSIX path of the profile of the 1st display just fine when run under OS X 10.4.11. But under 10.6, I can't seem to get it to work, it raises 'syntax error: Expected “,” but found identifier'.
    tell app "ColorSyncScripting"
    set prof to location of (display profile of display 1)
    try
    POSIX path of prof
    end try
    end tell
    (I should probably mention that I try to run the actual script from the commandline using osascript - ie. `osascript -e 'tell app "ColorSyncScripting"' -e 'set prof to location of (display profile of display 1)' -e 'try' -e 'POSIX path of prof' -e 'end try' -e 'end tell'`)
    Any suggestions are appreciated.

    The ColorSync scripting extension relied on FSSpecs and was not 64-bit compatible. Apple dropped it entirely, along with huge chunks of the ColorSync API for which there are currently no publicly documented replacements. You'll have to do it in C.

  • Hi,  This was not what I meant.     The requirement is:      Drag and drop any one of specific list

    Hi,
    This was not what I meant.
    The requirement is:
    Drag and drop any one of specific list of components say x, y,z in the parsys
    Only after the drag and drop of these components other components can be dragged to the parsys. So we can say that the parsys should allow only the specific components to be added first and only after that other components can be added.
    Thanks ,
    Dipti

    Hi there
    I'm guessing that you mean to ask if one is able to force a user to perform a drag-and-drop as part of a simulation?
    Unless you program it in Flash or some other application it isn't avaiable. Check the link below for more.
    Click here to view
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • Is it possible to combine pdfs from software containing the file by dragging and dropping them?

    We have a piece of software that we profile PDF files into it and then have a need to combine those PDFs into one file.  Is it possible to just drag and drop from the software into the combine files area?  I know if you open the files first, you can do that or if you save the documents locally, then you can combine them.  It would be ideal to just select the files in the software, then drag and drop them into the combine pdf window.  We are using Adobe Pro XI.

    Hi Hawk2000,
    The workflow you are talking about is very much possible with Acrobat and a good example is Microsoft Outlook from which we can select multiple e-mails and simply drag into Acrobat combine dialog box for combining.
    What happens when you drag files from you software? Is it public software?
    Can we test your software?
    Regards,
    Anoop

  • How can i get the address with drag and drop from address book into pages?

    I want to creat a letter withe the new pages. Normaly it was possible to put the adress from the adressbook with drag and drop into the letter. So it was possible to create one letter with many different adresses. But now I didn't find this function any more. How to do ist now?
    Withe best regards and I'm sorry for may bad english
    Klaus

    Sounds like you "upgraded" to Pages 5.
    Apple has removed over 90 features from Pages 5.
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&sid=3527487677f0c 6fa05b6297cd00f8eb9&mforum=iworktipsntrick
    Pages '09 should still be in your Applications/iWork folder.
    Archive/trash Pages 5, after Exporting your files to Pages '09, and rate/review it in the App Store, then get back to work.
    Peter

  • How to change the effect of drag and drop from MOVE to COPY in alv tree.

    Hi,
    I am using a tool in which now the behaviour on drag and drop is MOVE. I want to change it to COPY.
    But I do not know which parameter needs to be set and where.
    please help.
    Regards,
    Smita.

    Hi,
    Thanks for quick reply.
    The code goes on like this
    METHOD set_dd_behavior.
      DATA: l_copysrc(1) TYPE c,
            l_movesrc(1) TYPE c,
            l_droptarget(1) TYPE c.
    Set the Drag and Drop Flavors.
      CREATE OBJECT dd_behavior.
      READ TABLE reg_functions WITH KEY name_function = 'COPY'
      TRANSPORTING NO FIELDS.
      IF sy-subrc = 0.
        l_copysrc = 'X' .
      ENDIF.
      READ TABLE reg_functions WITH KEY name_function = 'CUT'
      TRANSPORTING NO FIELDS.
      IF sy-subrc = 0.
        l_movesrc = 'X' .
      ENDIF.
      READ TABLE reg_functions WITH KEY name_function = 'PASTE'
      TRANSPORTING NO FIELDS.
      IF sy-subrc = 0.
        l_droptarget = 'X' .
      ENDIF.
      CALL METHOD dd_behavior->add
      EXPORTING
      flavor = 'MOVE'
      dragsrc = l_movesrc
      droptarget = l_droptarget
      effect = cl_dragdrop=>move.
      CALL METHOD dd_behavior->add
      EXPORTING
      flavor = 'COPY'
      dragsrc = l_copysrc
      droptarget = l_droptarget
      effect = cl_dragdrop=>copy.
      CALL METHOD dd_behavior->get_handle
      IMPORTING handle = dd_behavior_handle.
    ENDMETHOD.
    Here what changes needs to be done.
    As I see once COPY is added and next time MOVE is added.
    I am able to check because I am not able to edit while debugging the value of effect.
    Please suggest.
    Warm regards,
    Smita.

  • If i use Ps5 the order lasso, drag and drop or letters the win vista crashes down. Can anybody help?

    If i use PS5 the order lasso,drag and drop or letters the win vista crashes down. Can anybody help me?

    Now that I'm looking at it, I don't have it... but I still have the problem:(. I rebooted the PRAM, I cleaned my permissions, run utilities checks, nothing helps, I'm at the end of my wits. I called apple - all I got was bad attitude... I don't know what to do, this disfunction makes it impossible for me to work....
    does anybody know what I could do to fix this issue?

  • I recently uploaded some pics and videos from an ipad and a camera. I put them all on Iphoto and backed them up in my personal folder. I then trimmed one of the videos and dragged and dropped that into the master folder(pictures). Its now gone!! HELP!?!?!

    I rencently added all my photo's from my Ipad and Camera. There were photos and videos on both. The import was done through Iphoto and then transfered to my backup in my pictures folder. I then took one of my videos and trimmed it and then addded that trimmed version to my back up(pictures)albumn. It asked If i wanted to replace existing photo or cancel and I hit replace. Now the file plays great on Iphoto but I am unable to share it through any form(facebook, Imessage etc) and in my back up(pictures) it says the file in only 87kb. I dragged and dropped it from Iphoto to the desk top along with another important video, when I hit get info on both of them one of them is a full sized video(50mb or whatever) and the other one(the one I am trying to recover) is only the 87kb. I want this full file avaiable to me how can I get it back?? it is already deleted off the camera??? please please help me.

    Garret,
    is your movie in your backup folder a Quicktime movie? Then probably only have the Quicktime wrapper in your backup folder, but not the referenced media in the file fork of the movie. If you see the full quality movie in iPhoto in QuickTime player, don't drag it from the browser to the Desktop, but use "File > Reveal in Finder > Original File" to show the movie in your iPhoto Library. Select the Movie when it is revealed and ctrl-click it to open it in Quicktime Player.
    Export it from Quicktime Player with "Export to" and share it to iTunes. This way it will be converted to a .mp4 movie that embeds the missing resources.
    You can drag the converted movie from iTunes to the Desktop or share it using to Media Browser to other applications.
    Regards
    Léonie

  • What is the policy for drag-and-drop in training mode?

    Hi,
    I've captured an application in training mode. It contains one drag-and-drop action which obviously is done in full motion recording.
    Only thing is, this doesnt work when you then do the simulation as a user.
    Can drag-and-drop working in this mode? It seems not.
    Can anyone advise?
    Thanks,
    Joan

    Hi there
    I'm guessing that you mean to ask if one is able to force a user to perform a drag-and-drop as part of a simulation?
    Unless you program it in Flash or some other application it isn't avaiable. Check the link below for more.
    Click here to view
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • PDF XFA form/internet browser/JAVA application/Drag and Drop

    Hi guys,
    I need to be able to open a PDF XFA form (a PDF document where I have some input controls and javascripts for validation) inside a JPanel.
    If this is not doable am thinking if i can open this pdf form in a web browser by launching it from my java application.
    And when I do this, I want to be able to drag and drop between the java application and the browser.
    Anyone can tell me if that is doable?
    Thanks and Regards,
    Rawad

    Tristan,
    I am stuck in the same place. Perhaps we could work on this together.
    I am trying to drag a single item from a JList to a text editor, Word, etc. I have two problems:
    1) I can't seem to get just the item in the JList to drag. It wants to drag the entire JList component.
    2) How does one define the remote application as the drop target? Have not found any examples either.
    Is the drop target actually the system clipboard?
    Rp

  • Problem using text boxes as the "image" to drag and drop over audio file

    I have been adding audio files to my page in iWeb (previous version, not '08), but I am having a problem giving them titles.
    When you first drag a file from iTunes into iWeb, it provides a space for you to drag and drop a picture. The online iWeb guide also says that you can drag a text box there instead of a picture.
    I created a text box with the text I would like to drop over the controller. However, it is no longer allowing me to drop the text box there. I used to be able to do this, and I don't know what I'm doing differently now. Any suggestions?
    Thanks!
    -- Will

    foobar2000 with the ipod plugin will allow you to drag/drop FLAC files and when it syncs the ipod, it converts the FLAC files on the fly. MUCH better than dealing with the crappy iTunes interface and having to pre-convert the files. I absolutely loathe iTunes and it just gets worse and worse!

  • How to use the palette or drag and drop functions in netbean?

    Is there anyone who can help me out on using drag and drop function in netbean to design GUI inteface..??
    Is palette is the tool that can be used to drag and drop.??
    thank you in advance.

    I actually really like the GUI builder in netbeans. I used to be a big eclipse user so I am very familiar with coding GUIs by hand, and most of what I do involves GUI's or at least swing.
    At first I hated netbeans, I hated that I couldn't edit the code most. Then I decided to take a deep breath and really examine the issue. What I discovered is that most of the edits I wanted to make but couldn't really weren't the right way to be doing it in the first place, for the rest the code is actually really easy to change you just have to know how.
    Now my palette is huge, probably about 250 objects in it organized into sections that work for me. Basically if I want a object to do something that is not already in the palette I simply write a new object and add it to the palette. I started small like with rounded buttons/progress bars, and as I got comfortable I now have some fairly advanced objects like grids, isometric grids, alpha composits, an animated hourglass countdown timer, and an animated "loading/activity" indicator that is not tied to a progress indicator.
    The main reason I stuck with the netbeans drag and drop GUI builder is it's layout manager is really a very nice layout manager, you couldn't pay me enough to go back to eclipse or codeing GUIs by hand, as I can now do in one day what used to take me several weeks.
    So what I am saying is stick with netbeans and the drag and drop, it sucks at first, but once you get to a point where you are comfortable with it and adding to the palette it will become a great tool.
    JSG

  • Hotkey to play the video / fullscreen / drag and drop

    1) When i try to play the video, its just zooming in and out. And i read the hotkeys help - it didn't  found any about that.
    2) How to fullscreen the video? There is no way to hide left side bar, that is ridiculous.
    3) How to drag and drop video or photos to Skype / Safari / iMovie, something else?
    That is first time when i use VLC to make a library, just because Photos app look like broken.

    Thanks a lot for that! Managed to get it to work finally.
    Sorry for the late response, I've only just decided to get back to doing the work.

  • Downloaded iTunes 9...but the Home Sharing "drag and drop" doesnt work

    I just downloaded iTunes 9 to my ASUS laptop and..well im trying to transfer some of my other library to this computer using the home sharing..but the simple "drag and drop" to add from the shared library to yours doesn't work at all. I tired re-installing iTUnes but it still doesnt work. Help!

    Okay, FWIW I just solved this on my machines...was tearing my hair out too!
    Drag/drop and settings/import buttons are enabled only when the shared library is a yellow icon, and not a blue icon. So, what's the difference?
    A blue icon indicates just plain vanilla sharing--no drag/drop or import is allowed. This type of sharing is enabled by turning on "Look for shared libraries" and "Share my library on my local network" in preferences on both machines.
    I did this and signed in under the same account on both machines but still only got the blue icon and couldn't drag/drop or import. Then I discovered it (and felt pretty dumb that I missed it).
    Make sure you go to the Advanced menu option and select "Turn On Home Sharing", and sign-in. Once you do this, you should get the yellow sharing icon and things will work smoothly.
    Again, just turning on sharing in preferences and signing-in (under the Store menu option) will not do the trick. You need to enable home sharing through the Advanced menu option.
    Hope that helps!

  • Ive lost the ability to drag and drop and photos in iphoto 5

    hi my powermac was doing fine yesterday . but today and cant drag and drop anything. can someone run me through a step by step guide of what the problem amy be and how to fix it. it would be much appreciated. thanks you

    Chris
    This is the v6 forum
    Launch Font Book (in your Applications folder).
    Select the Helvetica font. Is it enabled? If not, enable it. Even if it is, disable it and re-enable it.
    You do this via the Edit menu in Font Book, or using the little tick at the bottom of the font list.
    Regards
    TD

Maybe you are looking for

  • Good deal on a Macbook?

    I'm about to switch to a Macbook and was wondering if this was a good deal I have found on Craigslist. Black 2.0GHz 1GB ram 120 gb HD Snow Leopard, iWork, and iLife installed. $650 sound like a good deal to you? I need it for iWork essentially. Thank

  • Endless Loop: Ipod in Recovery Mode

    i have a 5th gen 30G Ipod that goes into recovery mode every time it is plugged into my computer. I will restore it to factory settings only to have it return to recovery mode. I have changed the drive name of the Ipod and also reformatted the hardri

  • Number of elements in an array

    Hi, I have been trying looking for a simple function to get number of elements is an array. Have gone though older posts but could not find answer to it. The function should work for following examples: char* name = "nInstruments" float state[] = {1.

  • Getting my query_only forms to populate  on_load rather than F8

    Hello there, I have created a main menu with buttons which opens up each and every form. call_form(getpath||'form_name'); When a form loads up, i still have to press F8 before records are populated into it. Is there a code that I have not included so

  • Problème de ''package'' dans InDesign

    Quand je tente de faire un package dans InDesign, il ne se termine pas.. il reste gelé à ''Save doc... Ensuite, quand je tente d'ouvrir le doc, la roue tourne sans cesse. Je dois forcer InDesign à quitter et quand j'ouvre à nouveau le programme, mon