Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

05slvrscape

macrumors member
Original poster
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.
 
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.


Code:
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.
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.