• 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
Satimage's "find text" command
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Satimage's "find text" command


  • Subject: Satimage's "find text" command
  • From: Richard Covert <email@hidden>
  • Date: Mon, 3 May 2004 03:19:18 -0500

Folks,

As part of an Applescript (as) script I make some temporary files. The
files end with .par2, .rar, and .r00 thru .r99 (the last files can be
between 00 and whatever depending the size of the original file).
Anyway, I want to move these files to a temp folder after they are
created earlier in the script. I am using Satimage's OSAX to do this.
But, I find that I need to surround the 'find text' command with a try
to trap out the files which DO not end with the pattern.

I have included my move subroutine as an example.

So, I do a 'find text' for only the files ending with .r00 the .r99. If
the find text fails then I try to see if the file ends with either .rar
or .par2, otherwise I ignore it. But it seems to be bad programming to
rely on an error for what would otherwise be a normal filename.

Satimage seems to consider a non-match an error so you have to trap the
error to process non-matches to 'find text'
Has anyone else tried the 'find text' command? Am I missing something??
Thanks



SAMPLE FOLDER AFTER MOVE
rarfiles:
email@hidden0+100.par2
email@hidden
email@hidden
email@hidden

on move_rar(src_folder, dest_folder)
tell application "Finder"
-- your commands go here
set rarfiles to list files of src_folder without invisibles
repeat with i from 1 to count of rarfiles
-- your commands go here
copy the ((item i of rarfiles) as string) to this_file
(*
satimage allows you to do a regular expression in a text. But, the
"find text"
command returns an ERROR if the match is not found. So, you need to
do a try around the "find text" command to trap the error that
MAY be returned.
So, I want to examine each file in the folder against the
pattherns ".rar", ".r00",...,".r99",".par2"
*)
(*
if (name of item i of rarfiles ends with ".rar") then
--display dialog "name of item i is " & name of item i
move file (item i of rarfiles) to folder ((srcFolder as string) &
"tmp")
end if
*)
(*
--set this_file to the name of this_file
display dialog "this_file is " & this_file
--set this_file to this_file as file
display dialog "the class of this_file is " & class of this_file
*)
set temp_result to ""
try
set temp_result to find text ".r[0-9][0-9]" in this_file with
string result and regexp
move (this_file as alias) to dest_folder

on error number errnum
if errnum = 1 then
if this_file ends with ".par2" or this_file ends with ".rar" then
move (this_file as alias) to dest_folder
end if
end if
end try

end repeat
end tell
end move_rar
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Satimage's "find text" command
      • From: Emmanuel <email@hidden>
  • Prev by Date: Adobe ImageReady
  • Next by Date: Re: joining several data files together (aka UNIX cat in AS)
  • Previous by thread: Adobe ImageReady
  • Next by thread: Re: Satimage's "find text" command
  • Index(es):
    • Date
    • Thread