• 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: Naming Files from List Ref
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Naming Files from List Ref


  • Subject: Re: Naming Files from List Ref
  • From: Paul Berkowitz <email@hidden>
  • Date: Mon, 02 Sep 2002 01:23:37 -0700

On 9/2/02 12:49 AM, "nellA hciR" <email@hidden> wrote:

> this solution works GREAT if you have consecutive id numbers but fails under
> the following condition with:
>
> Can't make item 21 of {"Cyan", "Magenta", "red", "Yellow", "Black",
> "Pantone072"} into a string.

The example given had the colors in consecutive order. there's absolutely no
reason why they shouldn't be in consecutive order, containing al the colors
needed. The job_name list can be in any order whatsoever, as I'd expect it
to be. Only the color list need be ordered.
>
> set originalJobText to "jobname_001.tif
> jobname_003.tif
> jobname_003.tif
> jobname_003.tif
> jobname_021.tif
> jobname_004.tif
> jobname_005.tif"
>
That's OK (above).

> set colorText to "001_Cyan
> 002_Magenta
> 021_red
> 003_Yellow
> 004_Black
> 005_Pantone072"

That's perverse - why would you need to muck them about like that? If you
absolutely have to, then it's a little more trouble, but not much (still not
worth $13,000):

set colorList to paragraphs of colorText
set colorCodeList to {}
set AppleScript's text item delimiters to {"_"}
repeat with i from 1 to (count colorList)
set code_Color to item i of my colorList
set item i of my colorList to text item 2 of code_Color
set end of colorCodeList to text item 1 of code_Color
end repeat

set finalList to {}
repeat with i from 1 to count (paragraphs of originalJobText) -- - 1?
set jobLine to paragraph i of originalJobText
repeat 1 times
set AppleScript's text item delimiters to {"_"}
set jobName to text item 1 of jobLine
set theCode to text item 2 of jobLine
set AppleScript's text item delimiters to {".tif"}
set theCode to text item 1 of theCode
set theIndex to my CollectUniqueItemIndex(colorCodeList, theCode)
if theIndex = 0 then
display dialog "There's a code not in the colorList: " & theCode
buttons {"Cancel", "Continue"} default button 1 with icon 2
--if button returned of result = "Cancel" then return --
[non-English, pre-1.8.3]
else
exit repeat
end if
end repeat -- 1 times, next repeat
set end of finalList to jobName & "_" & (item theIndex of colorList) &
".tif"
end repeat

set AppleScript's text item delimiters to {return}
set finalText to finalList as string
set AppleScript's text item delimiters to {""}
finalText


to CollectUniqueItemIndex(theList, theItem)

set theIndex to 0
repeat with i from 1 to (count theList)
set aListMember to item i of theList
if aListMember = theItem then
set theIndex to i
exit repeat
end if
end repeat

return theIndex

end CollectUniqueItemIndex




--
Paul Berkowitz
_______________________________________________
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: Naming Files from List Ref
      • From: rich allen <email@hidden>
    • Re: Naming Files from List Ref
      • From: Shane Stanley <email@hidden>
References: 
 >Re: Naming Files from List Ref (From: nellA hciR <email@hidden>)

  • Prev by Date: Re: Naming Files from List Ref
  • Next by Date: Bypass the Mail AppleScript Send Alert?
  • Previous by thread: Re: Naming Files from List Ref
  • Next by thread: Re: Naming Files from List Ref
  • Index(es):
    • Date
    • Thread