Set path to folder?  (Save cURL to folder) [Applescript]

I need to save a cURled file to a certain spot.  I'm really bad at this, so I'm probably missing something obvious.  here is my script:
set username to short user name of (system info)
set targetpath to POSIX path of (path to "Macintosh HD:Users:" & username & ":Library:Application\\ Support:minecraft:bin:minecraft.jar ")
set this_URL to "http://assets.minecraft.net/1_9-pre6/minecraft_server.jar"
(do shell script "curl -L " & this_URL & " -o " & POSIX path of the destination with administrator privileges) & targetpath

For a start, you're going about this the wrong way.
This is the wrong way to determine your destination location:
set username to short user name of (system info)
set targetpath to POSIX path of (path to "Macintosh HD:Users:" & username & ":Library:Application\\ Support:minecraft:bin:minecraft.jar ")
A much better way would be:
set targetPath to POSIX path of ((path to library folder from user domain as text) & "minecraft:bin:minecraft.jar")
By using 'path to library folder' you can find the localized, current user's library folder - that is, you don't ned to know the user's name, or the language of their OS, or the name of their hard drive, or any other details beyond the subdirectories.
Secondly, your url command is a little hard to decode due to the multiple levels of commands and parameters. For example, the 'with administrator priviliges is associated with the 'do shell script' but it looks like it's part of your curl. You already coerce targetPath to a POSIX path, so there's no need to do it again. Finally, the parameters are also wrong - the URL has to be the last parameter to curl.
I recommend a divide-and-conquer approach:
set targetPath to POSIX path of ((path to library folder from user domain as text) & "minecraft:bin:minecraft.jar")
set this_URL to "http://assets.minecraft.net/1_9-pre6/minecraft_server.jar"
set curl_command to "/usr/bin/curl -o " & targetPath & " " & this_URL
do shell script curl_command with administrator privileges
By breaking the script into separate statements that define your variables, build the curl command, and then execute it, it's easier to read (and debug).

Similar Messages

  • In an Excel template file, can I set the Folder Path in the SaveAs Dialog box?

    I have an Excel template file (xltm) and, with help from the forum, I now have a Workbook_BeforeSave subroutine to save the template as a macro enabled file (xlsm).  I’m so thankful for that help from Edward in the forum.
    I also want to set the default folder location to save the file. I really only need it when the template is saved as a new xlsm file, because if they open the xlsm file, it’s usually opened from the default folder path so any save would normally go back
    to where the file was opened.  However, with a template (even if the template is in the default folder) the Saved template reverts back to the user’s documents folder.
    Is there a good way to do this?
    I tried to modify the Workbook_BeforeSave code like this:
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim FolderDir As String
    Dim FileNameVal As String
    FolderDir = "Z:\save\data\place\"
    If SaveAsUI Then
    If Dir(WorkBookFolder, vbDirectory) <> "" Then
    Application.DefaultFilePath = WorkBookFolder
    End If
    FileNameVal = Application.GetSaveAsFilename(, "Excel Macro-Enabled Workbook (*.xlsm), *.xlsm")
    Cancel = True
    If FileNameVal = "False" Then 'User pressed cancel
    Exit Sub
    End If
    ThisWorkbook.SaveAs Filename:=FileNameVal & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
    Application.EnableEvents = True
    End If
    End Sub
    But there are a lot of checks that would need to be done.
    I'm not sure how to only default the folder saved only when they open the template, but not change it when they just open an already saved Excel file created by the template (with all the active content, macros, etc.).
    Alan Edwards

    Hi Alan,
    store the path\filename in the 1st argument:
    FileNameVal = Application.GetSaveAsFilename("C:\*.xlsm", "Excel Macro-Enabled Workbook (*.xlsm), *.xlsm")
    Andreas.

  • How do I set the default folder for file - open file... ?

    When I save a file, photo, etc., the default folder for OPENING a file becomes the last folder I SAVED to - even after closing and reopening Firefox. Is there a way to maintain the same default folder for opening files?
    Thanks.

    Originally posted by: kwarner.uneedspeed.net
    Well... I found over 200 bugs none of which seemed to talk about setting
    the default folder. I probably missed the relevant bug in the spew.
    I ask a question here as a last resort -- after I've done what I think
    is an appropriate search for answers.
    But thanks for your help in any case.
    Daniel Megert wrote:
    > DemonDuck wrote:
    >
    >> When I need to open a file not in the workspace, I use File -> Open File.
    >>
    >> But the default folder it opens is in C:\Documents and
    >> Setting\Administrator
    >>
    >> I would like File -> Open File to first open in someplace more
    >> reasonable -- like the workspace.
    >>
    >> How do I set the default folder for File -> Open File ????
    >
    >
    > Is your '?' key broken? Check bugzilla there's a feature request
    > regarding your question.
    >
    > Dani

  • How to set default pdf folder for Adobe 8.1.4

    Every time I want to open or save a file in Adobe I have to navigate through the computer to the folder I use for pdf files. Can I set a default folder somehow so Adobe always looks there first?
    Thanks,
    Richard

    > Can I set a default folder somehow so Adobe always looks there first?
    No.

  • Create a folder with permissions set to This Folder, subfolders

    Basically my app creates 4 folders that gives a specific user certain permissions.
    I can create the folder find, and i can give the user the correct permissions, but by defaulse it has Apply To set to this folder only, so if the user creates a folder, they wont have permissions to access it.
    I want to give it permissions that Apply to: This folder, subfolders, and files.
    I have spent hours upon hours trying different things, and trying to find the answer anywhere. Any help is greatly appreciated.
    Here is my code to create the folders:
    string mailDataPath = "E:\\Data\\MailData\\" + logonName;
    string userDataPath = "E:\\Data\\UserData\\" + logonName;
    string userProfilePath = "E:\\Data\\UserProfile\\" + logonName;
    string userSharedPath = "E:\\Data\\UserShared\\" + logonName;
    path[0] = mailDataPath;
    path[1] = userDataPath;
    path[2] = userProfilePath;
    path[3] = userSharedPath;
    //If folders do not exists, create them.
    for (int x = 0; x < pathAmount; x++)
    if (!Directory.Exists(path[x]))
    Directory.CreateDirectory(path[x]);
    //Sets folder permissions dependant on which folder it is
    if (path[x] != userProfilePath)
    DirectoryInfo info = new DirectoryInfo(path[x]);
    DirectorySecurity security = info.GetAccessControl();
    security.AddAccessRule(new FileSystemAccessRule(logonName, FileSystemRights.Modify, AccessControlType.Allow));
    info.SetAccessControl(security);
    else if (path[x] == userProfilePath)
    DirectoryInfo info = new DirectoryInfo(path[x]);
    DirectorySecurity security = info.GetAccessControl();
    security.AddAccessRule(new FileSystemAccessRule(logonName, FileSystemRights.FullControl, AccessControlType.Allow));
    info.SetAccessControl(security);

    Figured it out. It wasn't as difficult as i made it out to be.
    I just need to use 2 access rules
    DirectoryInfo info =
    new
    DirectoryInfo(path[x]);
    DirectorySecurity security = info.GetAccessControl();
    security.AddAccessRule(new
    FileSystemAccessRule(logonName,
    FileSystemRights.Modify,
    InheritanceFlags.ContainerInherit,
    PropagationFlags.None,
    AccessControlType.Allow));
    security.AddAccessRule(new
    FileSystemAccessRule(logonName,
    FileSystemRights.Modify,
    InheritanceFlags.ObjectInherit,
    PropagationFlags.None,
    AccessControlType.Allow));
    info.SetAccessControl(security);
    this is the code for the setting of the permissions.
    had to play around with it a bunch to get the correct inheritance.
    Im sorry i dont realy understand. Where do i put this code? Is there a guide for were to put this? Thanks for your help! :)

  • Setting correct Media Folder in 9.0.2

    Since version 7 (or before) I had always set as Itunes Media folder location a share on my Nas like "Q:\Music" and the two options "keep organized" and "copy when adding" checked.
    Itunes was able to create under Q:\Music the folder with the artist name and inside this the album folder etc.
    Starting from 9.0.2 (I think...) with those setting I have a strange behavior.
    If I leave Q:\Music as folder location, when I add a song he create the artist folder in Q:MusicMusic
    Actually, he create a second "Music" subfolder inside mine.
    So I though to cheat him setting "Q:\" as folder location, but in this case he create the artist folder on the ROOT of the disk !!
    Is this a bug ? what can I do to restore the previous situation ?
    Thanks in advance
    Message was edited by: SandroRiz

    @ Wakefields3 - Sorry not to have picked up on this earlier...
    Wakefields3 wrote:
    Hello tt2, I have been reading these posts and trying to get my head around how iTunes works.
    Currently I have D:\music and all the folders beneath this, including a new iTunes\Album Artwork and iTunes\Media.
    We previously had an earlier version of iTunes but have since purchased a new computer and loaded v9.
    Today I was looking at my folder structure and noticed many duplicates and incorrect spellings, so decided to manually go through and tidy up (using Windows 7 explorer).
    Now of course my iTunes library is showing many songs that it can't locate (go figure I should have just left the awful mess alone). I don't really want to have to go through and manually locate each file.
    Not a good move - unlike Windows Media Player, iTunes won't watch your media folders and catch up if you move things about manually. Changing files names also has no impact on tag values so changing the name of the Artist folder won't correct what you see in iTunes or on your iPod.
    I use iTunes Folder Watch (iTFW) to catch files that for one reason or another have been added or removed from the media folders. It's not so bad on adding new items but it rescans the libary after each delete which is rather inefficient. I've not used the feature but FolderWatch can try to maintain the rating if it can see a file has just moved location.
    If you want a simple list of all files that can no longer be found in iTunes create an empty playlist called Found. Select the Music source. Select all items with CTRL-A. Drag this selection onto the new playlist and hover over it holding the mouse button for several seconds until a number displays how many items should be copied. Release the mouse button. Although the number will be the number of items in the Music source only items that can be found will be added to the list. Make a new Smart Playlist called Missing. Match all rules *Playlist is Music* and *Playlist is not Found*. This playlist should contain all the items that are not where iTunes expects them to be and thus have a little exclamation mark. They can be removed en masse from iTunes with CTRL-A to select and SHIFT-DELETE. You can then add the currently unlinked files using ITFW or just get iTunes to scan your entire media folder.
    Note if you have any WAV files these don't support tags so data could be lost if you remove & add in this way. These are best reconnected by attemtping to Get info and then searching for the file in the new location before you worry about repairing the rest of the library.
    We also have an AppleTV, some movies and some tv programmes, and an iPod Nano that we have to keep track of.
    We have some old folders under Various Artist and Various Artists - no real consistency there.
    iTunes likes to put compilations in a Compilations folder. It has a custom tag field not used by other media management tools called *Part of a compilation*, any file with this flag set will be put in *Compilations\<Album>\## <Name>* and may be treated slightly differently on various flavours of iPods. Everything else is sorted as *<Album Artist|Artist><Album>\## <Name>*.
    For more gory details see my page at http://www.samsoft.org.uk/iTunes/grouping.asp - if you decide to let iTunes manage things then leave iTunes to tidy up as you update tags, otherwise I'd suggest standardising on Various Artists or using the Compilations folder before the tidy up described above.
    What I want to know is how to make maximise iTunes and help it work best.
    Use iTunes to manage your library where possible rather than Explorer or other tools. It's also a good idea to switch off the media update & organising features in Windows Media Player so it doesn't fight with iTunes.
    Therefore:
    1) Should I really change my folder structure to D:\iTunes?
    Not unless you want to. If the library was in the standard structure as in the illustration moving from D:\Music\iTunes to D:\iTunes would be trivially easy, but given that things are slightly disorganised I'd leave that until later.
    2) If so, can I just manually move the folders to be under D:\iTunes
    You would just move the folder iTunes from D:Music to D:\ then delete D:Music. Note Vista/Win 7 make this trivial manipulation complicatated by calculating the size of all the files that are going to be "moved" instead of getting on with it. They should in fact all stay just where they are with the one folder entry being maipulated. When Windows finishes the folder move click the icon for iTunes and when prompted naviagte to the library file in D:iTunes.
    3) How do I get the iTunes library to ignore the old path and look only at the new one (if I do move the folders)
    When you move the library this way iTunes should realise that the media folder location has changed and update the preference accordingly. You can check under *Edit > Preferences > Advanced*.
    4) If I do this I imagine I then let iTunes organise the albums - this is currently turned off.
    You don't have to do this... I manage my library manually as I don't like iTunes truncating file & folder names and prefer to keep a few sections of my library separate. WIth iTunes set to "Keep organised..." any updates you make to tag info. in iTunes should get reflected in the file strcuture and there's a valid argument that the underlying files & folders don't really matter, what matters is what you see inside the various applications you use to manage the library.
    5) And the big bug gear that got me into this trouble in the first place - when I import an album sometimes the artist's name is incorrectly spelt - is there a way around this?
    You can edit details before or after importing from CD. If you let iTunes manage your files then file & folder names get updated (with some limitations on string lengths), otherwise if you want to manually manage then you should where possible update in iTunes, tweak track names in Explorer (or use another tool), remove from iTunes and then reimport. This should be done Album by Album or Artist by Artist and iTFW can help catch any strays.
    6) And finally, I don't have the media for most of these songs - we left it in storage when we shifties countries, so I can't import again.
    Backup, backup, backup... As long as you have the files you can rebuild the library. Once you get your library organised backup the whole thing...
    *Fast backup for iTunes library (Windows Only)*
    Grab SyncToy 2.1, a free tool from MS. This can copy your entire iTunes library & any other media folders onto another hard drive or network share. You can then use SyncToy periodically to synchronise or echo your library to the backup. A preview will show which files need to be updated giving you a chance to spot unexpected changes and during the run only the changed files will be copied saving lots of time.
    tt2

  • How to set the deployment folder for the server

    Hello All,
    I'm a new bee to this SJWS. I'm using SJWS 7.U4.
    When i build my web application, it is creating the war file in some location; lets say xxx. I dont want to deploy every time (manually update the war file and then click on deployment pending). So how can i set the deploy folder's path to the xxx so that just the build and restart of the server is sufficient and the server picks the latest war. Please guide me. I think this type of configuration options are provided in many of the web servers.
    Thanks
    Deepak

    Look at auto deploy functionality [http://blogs.sun.com/amit/entry/auto_deploying_a_web_application]

  • C# Getting path of folder that is created in Visual Studio and it's located in app directory.

    Alright i created folder that will contain video resources for my app.But now i need to connect it with my code.I need to get file path of folder that i created in Visual Studio,but it needs to work on other machines.I tryed Path.Combined(Environment.GetCurrentDirectory
    + @"Video\Lekcija1.mp4") but it didn't work.Any suggestions?

    If you set the Build Action of the Lekcija1.mp4 file to Content (right-click on the file in the Solution Explorer in Visual Studio) and the Copy To Output Directory property to Copy always or Copy if newer you could use the following code to get the absolute
    path to the file:
    string codeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
    string fullPath = System.IO.Path.GetDirectoryName(codeBase) + "\\Video\\Lekcija1.mp4";
    Hope that helps.
    Please remember to mark helpful posts as answer to close your threads and please start a new thread if you have a new question.

  • Setting a default folder for exports

    I am sure when I migrated from Snow Leopard to Lion that it asked me to set a default folder to save files and exports.
    I set this to one I don't use and would like to amend it - how can I do this?

    Besides the location for Downloads, there is nothing in the OS itself that will do that.
    There is a third-party program called Default Folder which I think does something like that.

  • How do I set a different folder than the Windows MyDocuments/Downloads folder? I do not use 'My Documents' at all, all my saved files go to other hard drives for storage, and I do not want to bother with the My Docs route. I used to have downloads set to

    I want to set a different folder from the My Documents/Downloads folder for Firefox to put everything I download, like I used to have it. I recently rebuilt my computer and reinstalled everything from WinXP to security software to Firefox, and I cannot find any options anywhere to set a different folder like I used to have it... with the same software, other than it being a newer iteration of Ff. So tell me, am I losing my mind so bad that I just can't remember how I did it before, or have things changed so much that what I want is no longer possible? Please, someone tell me how to set it to do what I want, I can't stand to have what I do on my computer dictated by programmers who only think that they know what people want. If that sounds a little angry, I apologize with the disclaimer that I suffer from Post Traumatic Stress Disorder and therefore cannot handle frustration... and this kind of thing frustrates me to the point of rage.

    Tools > Options - General tab = Downloads
    Set your preferences there.

  • Can I set up a folder under a mailbox in the inbox?

    I receive 100 messages per day. 10 of them are labelled "Sales Leads." I want to set up a folder in my inbox so that I can route these 10 to a folder for prioritization. I would like to leave them there while adding notes to the email through the To-Do functionality. Once completed, I will move them to a folder "On My Mac" so that I have a history of them. I think I need to do it this way because I want to be able to see the emails and the To-Dos on my iPhone...and if I move them to "On My Mac" while they are still active, I won't be able to view them.
    Question 1: Am I approaching solving this problem the best way?
    Question 2: Assuming the answer is yes...how do I do it?

    Hi JAM, I'm not sure I can offer a solution, but . . . . .
    Apple literature refers to both 'Mailboxes & Folders, so you could consider the terms interchangeable. Having said that, when you look at the left column of 'Mail' the item named MAILBOXES contains all the mailboxes with basic functions.
    The items immediately below the inboxes, -Drafts, Sent, Trash & Junk - all contain sub-folders for messages relating to any given account. If you can't see those sub-folders, it's because you haven't used them yet. They will appear when needed. The same applies to 'Reminders'
    The items below, that are named after your email accounts, contain all the folders you create for that account. These folders reside on the web. They're 'IMAP business' and I personally find it useful to have them as separate entities as I can more clearly see where I'm putting things. For our purposes, consider them as living permanently on the web - though I know you don't use web mail.
    Now, if you create a new mailbox/folder for filing purposes, and if you choose the location 'On My Mac', you will create a mailbox/folder in ON MY MAC at left. This folder resides on your computer ONLY. You can add folders and nested folders here as you please. As long as you're backing up your Mac frequently, you'll be backing up these folders. When a backup occurs, it's not guaranteed to back up the mail which is still living on a mail server.
    The items MAILBOXES, REMINDERS, RSS, ACCOUNT NAME, ON MY MAC & SMART MAILBOXES (if you have any) can be dragged up or down to reposition them.
    As for rules, if you're out and about, you may have to set these up at your web mail site in order to filter messages before they arrive on your phone. If you do this, you should find that those rules have been applied, the next time you look into 'ACCOUNT NAME' on your Mac.
    Lastly, the only way to get to your created mailboxes/folders on your phone is, as you've found, by navigating to the email account itself. If you don't see all the mailboxes/folders you've created, QUIT the mail app on your phone and relaunch it. They should then appear.
    I hope this may be of some further use.
    Oh, and by the way, if you want to use 'Notes & To Do's' much, you may find it useful to go to 'Mail > Preferences' on your mac, click the 'Composing' tab and select where to create notes & to do's.

  • TS5376 I did as this article described.  The download was going smoothly until I got this error message "Click OK or enter alternate path to folder in installation package containing the file itunes.msi"   Where can I get "itunes.msi"  ??

    I did as this article described.  The download was going smoothly until I got this error message "Click OK or enter alternate path to folder in installation package containing the file itunes.msi"   Where can I get "itunes.msi"  ??

    (1) Download the Windows Installer CleanUp utility installer file (msicuu2.exe) from the following Major Geeks page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    (2) Doubleclick the msicuu2.exe file and follow the prompts to install the Windows Installer CleanUp utility. (If you're on a Windows Vista or Windows 7 system and you get a Code 800A0046 error message when doubleclicking the msicuu2.exe file, try instead right-clicking on the msicuu2.exe file and selecting "Run as administrator".)
    (3) In your Start menu click All Programs and then click Windows Install Clean Up. The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
    (4) In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
    (5) Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • Why setting the download folder ton an external HDD doesn't work? the downloaded files goes to My Documents (Windows)?

    Why setting the download folder ton an external HDD doesn't work? the downloaded files goes to My Documents (Windows)?

    I did what you said and updated FF, now the download goes to the external HDD that I specified, but now FF bugs, it freezes (not responing) :s
    I reinstalled it but it doesn't fix the problem. I don't know what to do :(

  • How to set up 3 fold folder

    How to set up 3 fold folder, I want 3 pages next ot each other, and one page has a different size.

    Create a new document
    On Page panel uncheck allow document pages to shuffle
    Then drag the pages 2 & 3 to the next of page one

  • Cannot Update - Error 1324: The path New Folder or the volume is invalid. Please enter it again.

    I have been trying to update Adobe reader but every time i trie to this message shows up: Error 1324: The path New Folder or the volume is invalid. Please enter it again. I am running on Windows XP SP3 and using the latest firefox browser. I am not sure if this question has already been answered in this forum so if it has a link to the thread would be appreciated.

    For investigating more on this issue we would need the install log. For creating install log follow the below steps:
    1. Go to start menu and run command
    2. Type Regedit and press enter key
    3. Go to the following path and create keys:
    HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Installer
    Reg_SZ: Logging
    Value: voicewarmupx
    then  Install Reader X update. Once you get the error message get the snapshot of error message and then Type %temp% and hit enter. Get the file name as  MSI----
    Provide the snapshot of error message as well as MSI log.

Maybe you are looking for