• 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: rich allen <email@hidden>
  • Date: Sun, 1 Sep 2002 22:02:22 -0800

one possible solution

(*
contents of file 'input_list'
=============================
jobname_001.tif
jobname_002.tif
jobname_003.tif
jobname_004.tif
jobname_005.tif

contents of file 'color_code'
=============================
001_Cyan
002_Magenta
003_Yellow
004_Black
005_Pantone072

*)

on ListToRecord(l)
local scriptText
set scriptText to "{+class usrf;: {"
set a to count l
set i to 1
repeat while i is less than a
set scriptText to scriptText & "\""
set scriptText to scriptText & (item i of l as text)
set scriptText to scriptText & "\",\""
set i to i + 1
set scriptText to scriptText & (item i of l as text) & "\""
if i is less than a then
set scriptText to scriptText & " ,"
end if
set i to i + 1
end repeat
set scriptText to scriptText & "}}"
run script scriptText
end ListToRecord
-- ----------------------------------------------------------------- on GetColors()
set colorList to {}
set fRef to open for access file "users:hcir:desktop:rename_proj:color_codes"
try
repeat
set entry to read fRef before return
copy characters 1 thru 3 of entry as string to the end of colorList
copy characters 5 thru -1 of entry as string to the end of colorList
end repeat
end try
close access fRef
return colorList
end GetColors
-- ----------------------------------------------------------------- on GetFileList()
set fRef to open for access file "users:hcir:desktop:rename_proj:input_list"
try
set fileList to {}
repeat
set entry to read fRef before return
copy entry to the end of fileList
end repeat
end try
close access fRef
return fileList
end GetFileList
-- ----------------------------------------------------------------- to GetColorName(aKeyString, aRecord)
try
(aRecord as text)
on error message
set recordText to text 12 thru -15 of message
end try
set keyPhrase to ("|" & aKeyString & "| of " & recordText)
try
set sr to run script keyPhrase
on error
error ("Can't get " & keyPhrase)
end try
return sr
end GetColorName
-- -----------------------------------------------------------------

set colorList to GetColors()
set colorRecord to ListToRecord(colorList)
set fileList to GetFileList()
set od to AppleScript's text item delimiters
set newNameList to {}
set AppleScript's text item delimiters to od
repeat with aFile in fileList
set AppleScript's text item delimiters to "_"
set firstPart to text item 1 of aFile
set AppleScript's text item delimiters to od
set colorCode to characters -7 thru -5 of aFile as string
set colorName to GetColorName(colorCode, colorRecord)
set newFileName to firstPart & "_" & colorName & "." & characters -3 thru -1 of aFile
copy newFileName to the end of newNameList
end repeat
newNameList


-- hcir

On Sunday, Sep 1, 2002, at 20:15 America/Anchorage, Mathew Baker wrote:

Hi,

I have been lurking on the list for awhile now but have come across a problem which doesn't seem to have been answered in the archives.

I have some tiff files of a colour separated postscript file output from a RIP. I need to have the colour names added to the filenames before they are passed onto our colour proofing software. The filenames are in the form of :-
jobname_001.tif
jobname_002.tif
jobname_003.tif
jobname_004.tif
jobname_005.tif

The numbers corresponds to the separation numbers. I have extracted the separation names from the postscript file prior to ripping and have them in a text file in the format of:-
001_Cyan
002_Magenta
003_Yellow
004_Black
005_Pantone072

I need to replace the separation name with the colour name so that the tif files are named as follows:-
jobname_Cyan.tif
jobname_Magenta.tif
jobname_Yellow.tif
jobname_Black.tif
jobname_Pantone072.tif
_______________________________________________
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: Paul Berkowitz <email@hidden>
References: 
 >Naming Files from List Ref (From: Mathew Baker <email@hidden>)

  • Prev by Date: Naming Files from List Ref
  • Next by Date: Re: Naming Files from List Ref
  • Previous by thread: Naming Files from List Ref
  • Next by thread: Re: Naming Files from List Ref
  • Index(es):
    • Date
    • Thread