• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Rewrite simple Finder tell statement to "do shell script"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rewrite simple Finder tell statement to "do shell script"


  • Subject: Re: Rewrite simple Finder tell statement to "do shell script"
  • From: Luther Fuller <email@hidden>
  • Date: Tue, 11 Sep 2012 09:39:06 -0500

On Sep 11, 2012, at 4:43 AM, Bert Groeneveld wrote:

tell application "Finder"
move all_foundImageNames to the_CLEANSTART_folder
end tell

Hi, can someone help to rewrite above simple Finder tell statement with "do shell script"?

I don't know if this will help or not. You will have to experiment with it.
I use this code to get an alias to a file I want to copy ...

try
mboxPath as alias
tell application "Finder" to (some folder of the result whose name extension is not "mbox") as alias
quoted form of (POSIX path of the result)
do shell script "find " & the result & " -name " & msgFileName
(POSIX file (item 1 of (text items of the result))) as alias
return the result
end try

I's been a couple of years since I wrote this, so I'm not totally familiar with the man page, but it "finds" the file named msgFileName within the folder the result . The file does not have to be located at the top level of that folder. It seems to be blindingly fast in Lion.

(I only use this code in Lion. In (Snow) Leopard I use a Finder script. It may work in (Snow) Leopard and perhaps I should rewrite my script ... some day.)

Each of the found files is copied using this handler ...

on copyFile(fileAlias, targetAlias, newFileName)
-- fileAlias is an alias to the source file, targetAlias is an alias to the destination folder and newFileName is a string
set sourcePath to (quoted form of POSIX path of (fileAlias as text))
set targetPath to (quoted form of (POSIX path of ((targetAlias as text) & newFileName)))
try
do shell script "cp -np " & sourcePath & space & targetPath
on error errText number errNr
display dialog "Error cp -np = " & errNr & return & errText
error number -128 --***********************
end try
try
return ((targetAlias as text) & newFileName) as alias
on error errText number errNr
display dialog "Error targetAlias = " & errNr & return & errText
error number -128 --***********************
end try
return {}
end copyFile --------------------------------------------------------------------

I forgot to remove the 'on error' code because I never got an error to remind me that it was there.
I've been using this without error for years.



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Rewrite simple Finder tell statement to "do shell script"
      • From: Luther Fuller <email@hidden>
References: 
 >Rewrite simple Finder tell statement to "do shell script" (From: Bert Groeneveld <email@hidden>)

  • Prev by Date: Re: Rewrite simple Finder tell statement to "do shell script"
  • Next by Date: Re: Script Debugger 5: Duplicate Selection Handler
  • Previous by thread: Re: Rewrite simple Finder tell statement to "do shell script"
  • Next by thread: Re: Rewrite simple Finder tell statement to "do shell script"
  • Index(es):
    • Date
    • Thread