Mac Script help needed

Discussion in 'macOS' started by 05slvrscape, Dec 12, 2009.

  1. 05slvrscape macrumors member

    Joined:
    Jul 17, 2008
    Location:
    Canada
    #1
    I am trying to create a script that will allow me to create a folder based on the name of the file and place the file in that folder. I have found one that is created to work on the desktop folder but have not been able to get it to function on the external drive. If anyone could help me out that would be great.

    The name of the external drive is Video 1 and is connected via USB if that matters.

    Here is what I have for the script so far.



    on adding folder items to this_folder after receiving added_items
    tell application "Finder"
    set new_folder to "Video 1"
    set copied_folders to make new folder at new_folder with properties {name:"New folders"}
    repeat with aItem in added_items
    set x to kind of aItem
    if x is not "Folder" then
    set y to name of aItem
    set AppleScript's text item delimiters to "."
    set filename to first text item of y
    set AppleScript's text item delimiters to ""
    set newplace to make new folder at copied_folders with properties {name:filename}
    move aItem to newplace
    end if
    end repeat
    end tell
    end adding folder items to


    any help would be greatly appreciated. I think the item I am missing is how to specify the right location for the external device.
     
  2. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #2
    Remember, external drives are located at /Volumes/ExternalName. I modified the script a little, and added code tags to make it easier to read.

    Code:
    on adding folder items to this_folder after receiving added_items
    	tell application "Finder"
    		set new_folder to "/Volumes/Video 1"
    		set copied_folders to make new folder at new_folder with properties {name:"New folders"}
    		repeat with aItem in added_items
    			set x to kind of aItem
    			if x is not "Folder" then
    				set y to name of aItem
    				set AppleScript's text item delimiters to "."
    				set filename to first text item of y
    				set AppleScript's text item delimiters to ""
    				set newplace to make new folder at copied_folders with properties {name:filename}
    				move aItem to newplace
    			end if
    		end repeat
    	end tell
    end adding folder items to
    
     

Share This Page