MACSCRPT Archives

August 2011

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mark Lively <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 24 Aug 2011 02:16:41 +0000
Content-Type:
text/plain
Parts/Attachments:
text/plain (59 lines)
On Aug 23, 2011, at 5:09 PM, SUBSCRIBE MACSCRPT Inyo55 wrote:

> Whoever can solve this will have my regard as being a Genius:
> 
> Here is the first part of my script.  It is a script to rename files.  The files are dropped onto the script to start it:
> 
> ----------------------------------------------------
> 
> 	tell application "Finder"
> 			
> 			try
> 				set jFolder to folder of item 1 of filelist --path of folder files were dropped from
> 				set jpath to folder of item 1 of filelist as text --make it a string to use.
> 				set AppleScript's text item delimiters to ":"
> 				set PMName to (text item 1 of jpath) & ":" & (text item 2 of jpath) & ":" & (text item 3 of jpath) & ":" as string 
> 				set afolder to (text item 1 of jpath) & ":" & (text item 2 of jpath) & ":" & (text item 3 of jpath) & 
> ":HotFolders:DestFolder
> 				set jobname to text item 3 of jpath
> 				set AppleScript's text item delimiters to {}
> 				if jpath does not end with "To Be Renamed:" then
> 					beep
> 					display dialog "Files must be in the 'To Be Renamed' folder of " & jobname & "." with icon stop buttons 
> {"Cancel"} default button 1
> 				end if
> 				
> 			on error errmsg
> 				display dialog errmsg
> 			end try
> 		end tell
> 
> -----------------------------------
> 
> In the above script, text item 1 of jpath should be "CF10_O".  Yet, if I ask the script to return jpath as a string, the volume name becomes 
> "CF10_O-4" which is not right.  I have no idea where the "-4" is coming from, it is not in the Mac Share name on the server.  Since the 
> volume name is not as it should be, the script cannot set afolder and errors out.
> 
> The server is using a util called Extremez-IP for Mac Shares; I don't know if that affects the name of volume shares.  Any ideas?
> thanks,
> Bob R.

When Appleshare mounts drives that have the same name, on the system they have a -1 -2 -3 -n so could be where the numbers are coming from.  

You might be better off comparing with the name of the folder rather than the path.

Tell application "Finder"
	if name of folder of item 1 of filelist does not end in "to be renamed" then beep
end

Another tip

	set afolder to ((text items 1 through 3 of jpath) & "HotFolders:DestFolder") as text


Also which version of the OS are you running? Are there any unicode paths as well?

Hope this helps

-Mark
Was thinking that this could probably run on anything from 7.5 to 10.7

ATOM RSS1 RSS2