I have applications that process InDesign files. They reside on a Windows file server. All documents always have their file extension “.indd”. In Snow Leopard, when a file is moved from folder A to folder B, sometimes a user can no longer double click on the file to open it in InDesign. The document shows that there is no application associated with the document; but the document icon clearly still is an InDesign icon for the user. An error message from the Finder usually says something like “can’t open application null” (not the exact wording). Our user’s computers have InDesign CS3, 4, and 5 installed. They have reset and “changed all” documents to open in InDesign CS3 multiple times. But every couple days this problem shows up, only on files moved around via script.
The script command that I commonly use is a shell script “mv blah blah”. I also do some “Finder tell” moves. I’ve not narrowed it down to using one or the other.
I have looked in my launchservices plist file and it appears that InDesign is set to handle documents ending in .indd. :
LSHandlerContentTag = indd
LSHandlerContentTagClass = public.filename-extension
LSHandlerRoleAll = com.adobe.indesign
Any reason why this information would go away or get corrupted or change ever? Why would this only happen on documents moved by a script?
I don’t have a solution but I might have an explanation. I noticed recently that not all file extensions are recognized as extensions. For example, try running this on one of the problem files and see if you get the proper extension.
set theFile to choose file
tell application "Finder"
set ext to name extension of theFile
end tell
So look at the results and see what you get. My guess is that it will show “” instead of “indd”. If this is the case then you know the problem is that the file extension isn’t being recognized.
I guess you could fix it by re-setting the name extension like this… of course you’d have to reset the name too because it would think that “.indd” was part of the name.
set theFile to choose file
set text item delimiters to "."
tell application "Finder"
try
set name of theFile to (text items 1 thru -2 of (get name of theFile)) as text
end try
set name extension of theFile to "indd"
end tell
set text item delimiters to ""
Change uti’s in Subtree New version
If you choose two files in finder with the one with the default app to open it with set, so that that file has the newest modification date, then this script will change all files with the same extension or kind in a subtree, - the folder you choose and any subfolders within. -To open with that default app.
property McUsr : "1.0 Maybe add some help or such"
set fileExt to ""
set resRec to divergingProperties(a reference to fileExt)
if resRec is not null then
set theRootOfTheTree to (choose folder with prompt "Choose a tree to change \"uti's\" within") as text
changeAllUtis(theRootOfTheTree, resRec, fileExt)
end if
on divergingProperties(fileExt)
local theSel, propCount, fileNmA, fileNmB, fPropsA, fPropsB, dateA, dateB, newFProps, oldFProps, changeRec
set propCount to 0
tell application "Finder"
set theSel to (get its selection) as alias list
if (count of theSel) is not 2 then
display dialog "Needs two files with same extension, where one of them is configured to be opened with another app"
-- rework som logic here
error number -128
end if
set fileNmA to item 1 of theSel as text
set fileNmB to item 2 of theSel as text
repeat with i from 1 to 2
if extension hidden of item i of theSel is true then set extension hidden of item i of theSel to false
end repeat
end tell
tell application "System Events"
set fPropsA to (get properties of item fileNmA)
set contents of fileExt to (name extension of fPropsA)
set fPropsB to (get properties of item fileNmB)
if not (name extension of fPropsA is equal to name extension of fPropsB) then
tell me
activate
display dialog "Needs two files with same extension, or of the same type where the two differs in the choice of default app to be opened with."
end tell
error number -128
-- utvide til å gå på type her:
else
-- choose which file you want to change all the uti's too.
set dateA to modification date of fPropsA
set dateB to modification date of fPropsB
if dateB > dateA then
set newFProps to fPropsB
set oldFProps to fPropsA
else
set newFProps to fPropsA
set oldFProps to fPropsB
end if
-- eventually changing attributes in order of appearance
if not (file type of newFProps is equal to file type of oldFProps) then
set propCount to propCount + 1
set changeRec to {file type:(file type of newFProps)}
end if
-- so we are basically clear about what from what properties the uti data will be set.
if not (kind of newFProps is equal to kind of oldFProps) then
set changeRec to {kind:(kind of newFProps)}
if propCount > 0 then
set changeRec to changeRec & {kind:(kind of newFProps)}
else
set changeRec to {kind:(kind of newFProps)}
end if
set propCount to propCount + 1
end if
if not (creator type of newFProps is equal to creator type of oldFProps) then
if propCount > 0 then
set changeRec to changeRec & {creator type:(creator type of newFProps)}
else
set changeRec to {creator type:(creator type of newFProps)}
end if
set propCount to propCount + 1
end if
if not (type identifier of newFProps is equal to type identifier of oldFProps) then
if propCount > 0 then
set changeRec to changeRec & {type identifier:(type identifier of newFProps)}
else
set changeRec to {type identifier:(type identifier of newFProps)}
end if
set propCount to propCount + 1
end if
if not (default application of newFProps is equal to default application of oldFProps) then
if propCount > 0 then
set changeRec to changeRec & {default application:default application of newFProps} -- problem her
else
set changeRec to {default application:(default application of newFProps)}
end if
set propCount to propCount + 1
end if
end if
end tell
if propCount > 1 then -- let the show begin
-- changeUtiForFileOLD(fileNmB, changeRec)
return changeRec
else
return null
end if
end divergingProperties
on changeUtiForFile(theFile, theChanges)
local changedProperty
log " thefile : " & theFile
tell application "System Events"
try
set changedProperty to file type of theChanges
-- set file type of file theFile to changedProperty
set properties of file theFile to {file type:changedProperty}
on error
-- goof
end try
try
set changedProperty to kind of theChanges
-- set kind of file theFile to changedProperty
set properties of file theFile to {kind:changedProperty}
on error
-- goof
end try
try
set changedProperty to creator type of theChanges
-- set creator type of file theFile to changedProperty
set properties of file theFile to {creator type:changedProperty}
on error
-- goof
end try
try
set changedProperty to type identifier of theChanges
-- set type identifier of file theFile to changedProperty
set properties of file theFile to {type identifier:changedProperty}
on error
-- goof
end try
try
set changedProperty to default application of theChanges
-- set default application of file theFile to changedProperty
set properties of file theFile to {default application:changedProperty}
on error
-- goof
end try
end tell
end changeUtiForFile
on changeAllUtis(theRootOfTheTree, theChangeRec, theFileExt)
local fileText
tell application "Finder"
set tSelectedFiles to (every file of folder theRootOfTheTree whose extension hidden is true)
repeat with aFile in tSelectedFiles
set extension hidden of aFile to false
end repeat
-- copy or move over files of the specified type(s)
set tSelectedFiles to (every file of folder theRootOfTheTree whose name extension is equal to theFileExt) as alias list
if tSelectedFiles ≠{} then
repeat with aFile in tSelectedFiles
set fileText to aFile as text
my changeUtiForFile(fileText, theChangeRec)
end repeat
end if
-- copy over the folders, calling this handler recursively
set tFolders to (every folder of folder theRootOfTheTree)
repeat with tThisFolder in tFolders
my changeAllUtis(tThisFolder as alias, theChangeRec, theFileExt)
end repeat
end tell
end changeAllUtis