Filename into an URL

Discussion in 'Mac Programming' started by macaper, Oct 3, 2014.

  1. macaper macrumors newbie

    Joined:
    Oct 3, 2014
    #1
    Is it possible to make a folderscript that make an static URL address
    like www.yourdomain.com/staticfoldername/copy file name from newadded file.suffix/.

    Exampel: My new fil is test.jpg. I drop it into a folder with the name Images
    Now i want to make a script that sends an email with an url in:

    http://www.mydomain.com/Images/test.jpg.

    I can do all of it except get the filename into the email.
     
  2. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    I was going to post a code snippet enclosed in code tags but I got this :
     

    Attached Files:

  3. macaper thread starter macrumors newbie

    Joined:
    Oct 3, 2014
    #3
    Thanks for your fast answer

    It worked just like I wanted, but is it possible to make a script that just take the addad file an make an URL of that, not the other files in the folder. I also wonder if it is possible to put the filename in the middle of the URL like below

    www.mydomain.com/foldername/filename.jpg?login=get:get

    In this URL is everything static except "filename.jpg" that I want to be the name of the file I adds to the folder.
     
  4. macaper thread starter macrumors newbie

    Joined:
    Oct 3, 2014
    #4
    I saw one ing more

    I didn't understand this at first, but now the files will be sent to the trash. What should I write if I want to send it to another folder instead

    thanks in advance
     
  5. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #5
    Replace this :

    Code:
    tell application "System Events"
    	...
    end tell
    with this :

    Code:
    tell application "System Events"
    	set this_folder_name to this_folder's name
    	set these_items_names to {}
    	repeat with this_item in these_items
    		set end of these_items_names to name of this_item
    	end repeat
    end tell
    
    and this :

    Code:
    set end of filenamesURL to encode_text(base_URL & this_folder_name & "/" & this_item_name, false, false)
    
    with this :

    Code:
    set end of filenamesURL to encode_text(base_URL & this_folder_name & "/" & this_item_name & "?login=get:get", false, false)
    
    Example :

    Code:
    tell application "Finder" to move these_items to folder "Done" of folder "Images" of folder "flowerimages" of folder "Desktop" of home
    -- or
    -- same thing as above but as an alias
    tell application "Finder" to move these_items to alias "MavericksDP:Users:kryten:Desktop:flowerimages:Images:Done:"
    Note : Look at the attached thumbnail for the folder structure.
     

    Attached Files:

  6. macaper thread starter macrumors newbie

    Joined:
    Oct 3, 2014
    #6
    Many thank's

    I have been away for a couple of day's, but today did I try your new code and everything worked just like I wanted. Thank's a lot
     

Share This Page