Vous lisez mes messages et vous faites bien. Le 23/05/08 15:17, Jolly Roger
a écrit :
> In article ,
> Jean-Marie Schwartz wrote:
>
>> Vous lisez mes messages et vous faites bien. Le 23/05/08 9:43, Loic a
>> écrit :
>>
>> I sent you at your private address a script (or ebtter said an application)
>> that sorts things out.
>> I myself did not write it unfortunately. It shall return a dialog showing
>> what version the file was last saved in, even PC or Mac.
>> Feel free to open it and learn more about it. Edit it to your own goals.
>
> Jean-Marie: Why not post the script here so that others may benefit from
> it as well? Isn;t that the whole point of news groups??
Here it is (I wasn't able to copy-paste from Script Editor...):
[code]
global biblio
on open fileList
set nDoc to count fileList
if nDoc > 1 then quickSort(fileList, 1, nDoc)
repeat with aDoc in fileList
set biblio to 0
set filePath to aDoc as string
if filePath ends with ":" then
display dialog "C¹était un dossier !
Il ne faut déposer que des fichiers
sur ce droplet." buttons "OK" default button 1 with icon 0
else
set fileInfo to (info for file filePath)
set docName to name of fileInfo
set fileCreator to ""
set fileType to ""
try
set fileCreator to file creator of fileInfo
end try
try
set fileType to file type of fileInfo
end try
if fileCreator = "XPR3" and fileType = "TEXT" then
set tagVers to getTagVers(filePath)
if tagVers is not 0 then
if tagVers is {0, 0} then
infTags0(docName)
else
set progVers to item 1 of tagVers
set platForm to item 2 of tagVers
infTags1(docName, progVers, platForm)
end if
else
infDict(docName)
end if
else if fileCreator = "ttxt" and fileType = "TEXT" then
set docVers to getVers(filePath)
if docVers = "Ce n¹est pas un document XPress." then
set tagVers to getTagVers(filePath)
if tagVers is not 0 then
if tagVers is {0, 0} then
infTags0(docName)
else
set progVers to item 1 of tagVers
set platForm to item 2 of tagVers
infTags2(docName, progVers, platForm)
end if
else
infDoc(filePath, fileType, docName, "Ce")
end if
else
infUser2(filePath, docName, docVers)
end if
else if fileCreator = "????" and fileType = "????" then
set tagVers to getTagVers(filePath)
if tagVers is not 0 then
if tagVers is {0, 0} then
infTags0(docName)
else
set progVers to item 1 of tagVers
set platForm to item 2 of tagVers
infTags3(filePath, docName, progVers, platForm)
end if
else
set docVers to getVers(filePath)
if docVers is not "0" then
infDoc(filePath, fileType, docName, docVers)
else
display dialog "Il y avait un problème lors
de la lecture du fichier." buttons "OK" default button 1 with icon 2
end if
end if
else
set docVers to getVers(filePath)
if docVers is not "0" then
infDoc(filePath, fileType, docName, docVers)
else
display dialog "Il y avait un problème lors
de la lecture du fichier." buttons "OK" default button 1 with icon 2
end if
end if
end if
end repeat
end open
on quickSort(a, L, R)
set i to L
set n to R
set aRef to item L of a as text
repeat while i < n
repeat while (aRef < item n of a) and (i < n)
set n to n - 1
end repeat
if n ‚ i then
set item i of a to item n of a
set i to i + 1
end if
repeat while (aRef > item i of a) and (i < n)
set i to i + 1
end repeat
if n ‚ i then
set item n of a to item i of a
set n to n - 1
end if
end repeat
set item n of a to aRef
if L < n then
quickSort(a, L, n - 1)
end if
if R > i then
quickSort(a, i + 1, R)
end if
return a
end quickSort
on getTagVers(filePath)
try
set tagsClue to read file filePath for 11
on error
return {0, 0}
end try
if tagsClue contains "7" then
set tagsClue to read file filePath for 24
set charList to {}
repeat with i from 1 to 24
set curChar to character i of tagsClue
set curCode to ASCII number of curChar
if curCode is greater than 45 and curCode is less than 127 then
set end of charList to curChar
end if
end repeat
set tagsClue to charList as string
end if
if tagsClue starts with "<" then
set filterVers to text 3 thru 6 of tagsClue
set platVers to text 9 thru 10 of tagsClue
if filterVers = "7.10" then
set progVers to "7.1"
else if filterVers = "7.00" then
set progVers to "7.0"
else if filterVers = "6.50" then
set progVers to "6.5"
else if filterVers = "6.10" then
set progVers to "6.1"
else if filterVers = "4.00" then
set progVers to "6.0"
else if filterVers = "3.00" then
set progVers to "5.0x"
else if filterVers = "2.05" then
set progVers to "4.11"
else if filterVers = "2.03" then
set progVers to "4.04"
else if filterVers = "2.02" then
set progVers to "4.02 oder 4.03"
else if filterVers = "2.00" then
set progVers to "4.0"
else if filterVers = "1.70" then
set progVers to "3.3x"
else if filterVers = "1.60" then
set progVers to "3.2x"
else if filterVers = "1.50" then
set progVers to "3.1"
else
set progVers to "inconnu"
end if
if platVers = "e0" then
if filterVers starts with "7" then
set platForm to "Mac Roman (x-mac-roman)"
else
set platForm to "Macintosh"
end if
else if platVers = "e1" then
if filterVers starts with "7" then
set platForm to "Windows Latin (windows-1252)"
else
set platForm to "Windows"
end if
else if platVers = "e2" then
if filterVers starts with "7" then
set platForm to "Western (iso-8859-1)"
else
set platForm to "Latin 1"
end if
else if platVers = "e3" then
set platForm to "Japanese (shift_jis)"
else if platVers = "e4" then
set platForm to "Korean (EUC-KR)"
else if platVers = "e6" then
set platForm to "Chinese Trad. (big 5)"
else if platVers = "e6" then
set platForm to "Chinese Simp. (gb2312)"
else if platVers = "e8" then
set platForm to "Unicode (UTF-16)"
else if platVers = "e9" then
set platForm to "Unicode (UTF-

"
else
set platForm to "inconnu"
end if
return {progVers, platForm}
else
return 0
end if
end getTagVers
on infTags0(docName)
display dialog "Il y avait un problème lors
de la lecture de l¹info du fichier
« " & docName & ". »
Désolé." buttons "OK" default button 1 with icon 2
end infTags0
on infTags1(docName, progVers, platForm)
if progVers is not 0 then
display dialog "Le fichier balises XPress
« " & docName & " »
a probablement été exporté depuis
QuarkXPress v." & progVers & "
[ " & platForm & " ]" buttons "OK" default button 1 with icon 2
else
display dialog "Le fichier balises XPress
« " & docName & " »
ne contient pas de numéro de version
du filtre XPress Tags." buttons "OK" default button 1 with icon 2
end if
end infTags1
on infTags2(docName, progVers, platForm)
if progVers is not 0 then
display dialog "Le fichier balises XPress
« " & docName & " »
a probablement été préparé pour
QuarkXPress v." & progVers & "
[ " & platForm & " ]" buttons "OK" default button 1 with icon 2
else
display dialog "Le fichier balises XPress
« " & docName & " »
ne contient pas de numéro de version
du filtre XPress Tags." buttons "OK" default button 1 with icon 2
end if
end infTags2
on infTags3(filePath, docName, progVers, platForm)
set dResult to button returned of (display dialog "Le fichier balises
XPress
« " & docName & " »
a probablement été préparé pour
QuarkXPress v." & progVers & "
[ " & platForm & " ]
Mais le créateur et le type du fichier
doivent être rétablis, sinon on
ne peut pas l¹importer dans XPress." buttons {"Ne rien faire", "Rétablir"}
default button 2 with icon 2)
if dResult is "Rétablir" then
try
tell application "Finder" to set creator type of file filePath
to "XPR3"
end try
try
tell application "Finder" to set file type of file filePath to
"TEXT"
end try
else
return
end if
end infTags3
on infDict(docName)
display dialog "Le fichier
« " & docName & " »
pourrait être un dictionnaire auxiliaire
QuarkXPress." buttons "OK" default button 1 with icon 2
end infDict
on getVers(filePath)
try
set versionClue to read file filePath for 12
on error
return "0"
end try
if character 5 of versionClue = "ÿ" then set biblio to 1
if versionClue contains "MM" and versionClue contains "PR3" then
if versionClue ends with "?" then
return "QuarkXPress 3.x (Mac)"
else if versionClue ends with "A" then
return "QuarkXPress 4.x (Mac)"
else if versionClue ends with "B" then
return "QuarkXPress 5.x (Mac)"
else if versionClue ends with "C" then
return "QuarkXPress 6.x (Mac)"
else if versionClue ends with "D" then
return "QuarkXPress 7.x (Mac)"
else
return "inconnu (Mac)"
end if
else if versionClue contains "II" then
set testChar to character 11 of versionClue
if character 11 of versionClue = "?" then
return "QuarkXPress 3.x (Windows)"
else if character 11 of versionClue = "A" then
return "QuarkXPress 4.x (Windows)"
else if character 11 of versionClue = "B" then
return "QuarkXPress 5.x (Windows)"
else if character 11 of versionClue = "C" then
return "QuarkXPress 6.x (Windows)"
else if character 11 of versionClue = "D" then
return "QuarkXPress 7.x (Windows)"
else
return "inconnu (Windows)"
end if
else
return "Ce n¹est pas un document XPress."
end if
end getVers
on infDoc(filePath, fileType, docName, docVers)
if docVers starts with "Ce" then
infUser0(docName)
else
if fileType is not "" then
if docVers contains "6" or docVers contains "7" then
set okay to 1
if fileType = "XPRJ" then
set curDoc to "du projet"
else if fileType = "XPRT" then
set curDoc to "du gabarit"
else if fileType = "XLIB" then
set curDoc to "de la bibliothèque"
else
set okay to 0
infUser2(filePath, docName, docVers)
end if
else
set okay to 1
if fileType = "XDOC" then
set curDoc to "du document"
else if fileType = "XTMP" then
set curDoc to "du gabarit"
else if fileType = "XLIB" then
set curDoc to "de la bibliothèque"
else
set okay to 0
infUser2(filePath, docName, docVers)
end if
end if
else
set okay to 0
set curDoc to "du machin"
infUser1(curDoc, docName, docVers)
end if
if okay = 1 then
infUser1(curDoc, docName, docVers)
end if
end if
end infDoc
on infUser0(docName)
display dialog "Le document
« " & docName & " »
ne semble pas être un fichier XPress." buttons "OK" default button 1 with
icon 2
end infUser0
on infUser1(curDoc, docName, docVers)
display dialog "La version " & curDoc & "
« " & docName & " » :
" & docVers & "." buttons "OK" default button 1 with icon 1
end infUser1
on infUser2(filePath, docName, docVers)
if biblio = 1 then
set whatKind to "de la bibliothèque"
else
if docVers contains "6" or docVers contains "7" then
set whatKind to "du projet"
else
set whatKind to "du document"
end if
end if
set dResult to button returned of (display dialog "La version " &
whatKind & "
« " & docName & " » :
" & docVers & "
Mais le créateur et le type du fichier
doivent être rétablis, sinon on
ne peut pas l¹ouvrir avec XPress." buttons {"Ne rien faire", "Rétablir"}
default button 2 with icon 2)
if dResult is "Rétablir" then
try
tell application "Finder" to set creator type of file filePath
to "XPR3"
end try
if docVers contains "6" then
if biblio = 0 then
try
tell application "Finder" to set file type of file
filePath to "XPRJ"
end try
else
try
tell application "Finder" to set file type of file
filePath to "XLIB"
end try
end if
else
if biblio = 0 then
try
tell application "Finder" to set file type of file
filePath to "XDOC"
end try
else
try
tell application "Finder" to set file type of file
filePath to "XLIB"
end try
end if
end if
else
return
end if
end infUser2
[/code]
--
Jean-Marie
« Mi ricordo che un giorno... in mezzo a noi venne un tipo... che ogni cosa
pensava giusto e la fonte della vita era in lui disse una frase... mi rimase
impressa: "Alzati ...e cammina!"... » (Adriano Celentano, «Cammino»)
>> Stay informed about: File version