Create a New Folder in a Folder on an iPod.....

I’m written a script to backup some work to my iPod.

I’d like to store the backup in a folder called “Work Backup”, in a folder called “Backup” but I’m having a problem getting my script to create the “Work backup” folder.

Here’s what I’ve got so far:

set BackupFolder to "Backup:"
	set WorkBackupFolder to "Work Backup"
	set MyLocation to this_iPod & BackupFolder & WorkBackupFolder as string
	try
		get MyLocation as alias
	on error
		tell application "Finder"
			make new folder at this_iPod & BackupFolder with properties {name:WorkBackupFolder}
		end tell
	end try

The script errors with “Finder got an error: Can’t get some object.”

Model: iMac
AppleScript: 2.1.1
Browser: Safari 523.12
Operating System: Mac OS X (10.4)

Hi,

it could depend on the question: what exactly contains the variable this_iPod? :wink:

Sorry I cut my script down to much…

The “this_iPod” comes from an Apple created script which detects if an iPod is connected.

Here’s the rest of the script:

tell application "SystemUIServer"
	activate
	display dialog "This will Sync info to your iPod" buttons {"Cancel", "Continue"} cancel button 1 default button 2 with title "iPod Sync" giving up after 3 ¬
		with icon alias ((path to startup disk) & "Applications:isync.app:Contents:Resources:iSyncApplicationIcon.icns" as string)
end tell
if the button returned of the result is "cancel" then
	stop
else
	
	------------------
	(* Check for connected iPods. Taken from an AppleScript produced by Apple inc *)
	--on run
	-- check for iPods
	set the mounted_iPods to my locate_iPods()
	-- check for iPod count
	if the mounted_iPods is {} then
		error "No iPod is connected to this computer."
	else if the (count of the mounted_iPods) is greater than 1 then
		-- choose iPod
		set the ipod_names to {}
		repeat with i from 1 to the count of the mounted_iPods
			set this_iPod to item i of the mounted_iPods
			tell application "Finder"
				set the end of the ipod_names to the name of this_iPod
			end tell
		end repeat
		set this_name to (choose from list ipod_names with prompt "Pick the iPod to use:") as string
		if this_name is "false" then error number -128
		repeat with i from 1 to the count of the ipod_names
			if item i of the ipod_names is this_name then
				set this_iPod to item i of the mounted_iPods
				exit repeat
			end if
		end repeat
	else
		set this_iPod to item 1 of the mounted_iPods
	end if
	
	
	set BackupFolder to "Backup:"
	set WorkBackupFolder to "Work Backup"
	set MyLocation to this_iPod & BackupFolder & WorkBackupFolder as string
	try
		get MyLocation as alias
	on error
		tell application "Finder"
			make new folder at this_iPod & BackupFolder with properties {name:WorkBackupFolder}
		end tell
	end try
	
end if
--end run
on locate_iPods()
	set the volumes_directory to "/Volumes/" as POSIX file as alias
	set the volume_names to list folder volumes_directory without invisibles
	set mounted_iPods to {}
	repeat with i from 1 to the count of volume_names
		try
			set this_name to item i of volume_names
			set this_disk to ("/Volumes/" & this_name & "/") as POSIX file as alias
			set these_items to list folder this_disk
			if "iPod_Control" is in these_items then
				set the end of the mounted_iPods to this_disk
			end if
		end try
	end repeat
	return mounted_iPods
end locate_iPods

I guessed that the class of the variable is an alias


.
set BackupFolder to "Backup:"
	set WorkBackupFolder to "Work Backup"
	set MyLocation to (this_iPod as text) & BackupFolder & WorkBackupFolder
	try
		get MyLocation as alias
	on error
		tell application "Finder"
			make new folder at (this_iPod as text) & BackupFolder with properties {name:WorkBackupFolder}
		end tell
	end try
.

Thanks for the reply but unfortunately it doesn’t work :frowning:

The Script errors with: "Finder got an error: Can’t make class folder.

does the folder “Backup” already exist on the iPod?
The script creates only the subfolder

Yep, it’s already there

Yep

strange, I tested it on Leopard and Tiger and it worked fine.
Is the iPod locked or don’t you have access privileges?

Double Checked and I’ve got full access and it’s not locked.

When I look at the event log to shows this:

tell application "Finder"
	make new folder at "iDonut:Backup:" with properties {name:"Work Backup"}
		"Finder got an error: Can't make class folder."

But if I create a new script and run this:

tell application "Finder"
	make new folder at "iDonut:Backup:" with properties {name:"Work Backup"}
		end tell

The script works, very strange.