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:
Emmett Gray <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 24 Aug 2011 09:42:47 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (42 lines)
At 10:00 PM -0400 8/23/11, Inyo55 <[log in to unmask]> 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.  Th=
>e files are dropped onto the script to start it:

<snip>

My suggestion is to try removing the Finder from the equation and use POSIX paths and shell commands instead.

Make this into a droplet and see what you get:
on open filelLst
   set fileList to (POSIX path of fileList as string)
   set AppleScript's text item delimiters to "/"
   display dialog text item 3 of fileList
end open

The POSIX path will start with /Volumes/<your bad volume>, which is why you need to get item 3 (there's an empty first item before the first slash).

If this name is correct, you have a solution without bothering with the cause of your problem. I didn't quite understand where you are putting the renamed files, and how they are being renamed, but this script works to move them up one level, keeping the original name and you can adjust as needed, using the elements of the path you want and whatever renaming function:

on open fileList
   set fileList to (POSIX path of fileList as string)
   set AppleScript's text item delimiters to "/"
   set folderName to text item -2 of fileList
   set fileName to text item -1 of fileList
   --set fileName to something else? Rename here
   if folderName is not "To Be Renamed" then
      beep
      display dialog folderName
      --etc
   else
      set newPath to text item 1 of fileList & "/" & text item 2 of fileList & "/" & text item 3 of fileList & "/" & "HotFolders/Destfolder/" & fileName --watch wrap for this line
      set newPath to quoted form of newPath
      set fileList to quoted form of fileList
      --display dialog newPath --check before execution
      do shell script "ditto " & fileList & " " & newPath
      --do shell script "rm -f " & fileList --removes original
   end if
end open

ATOM RSS1 RSS2