Get File Type/Creator?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Get File Type/Creator?
Hi everyone,
I have several versions of InDesign installed....
Is there a way to drop an InDesign file onto a LiveCode app that determines the files (version/creator?) and then opens the file with the appropriate InDesign version? I looked at the LC dictionary and found "fileType" but it seems that function is only used for setting the file type for files created by LC.
Thanks,
Jon
I have several versions of InDesign installed....
Is there a way to drop an InDesign file onto a LiveCode app that determines the files (version/creator?) and then opens the file with the appropriate InDesign version? I looked at the LC dictionary and found "fileType" but it seems that function is only used for setting the file type for files created by LC.
Thanks,
Jon
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Get File Type/Creator?
Hi Jon,
I think you may get creator and file type using "detailed files" (OS X only).
Best regards
Jean-Marc
I think you may get creator and file type using "detailed files" (OS X only).
Best regards
Jean-Marc
https://alternatic.ch
Re: Get File Type/Creator?
Yes, but only the abbreviation (creator) of the application that created the file and NOT the version of the app used for it.
Re: Get File Type/Creator?
Is there a shell command that could be invoked within a script that could determine application version?
Thanks,
Jon
Thanks,
Jon
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Get File Type/Creator?
Of a document? Unlikely. That would require the app vendor to use a different creator code for each version, something I've seen only very few do. And since creator codes were largely deprecated with modern versions of OS X, I'd be surprised if vendors still bother to register them at all (does Apple even maintain that registry?).
If the document launches the correct version when double-clicked in the Finder, you can use LC's "launch document" command.
If not, you may investigate whether the document file species the version somewhere in its header, and store the paths to the various versions of the app you have installed, and use the "launch" command to launch the appropriate version for a given document.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Get File Type/Creator?
Files INDT are pure binary, so you can't read it.
Files INX are plain XLM, so you can try to extract some informations.
Files INX are plain XLM, so you can try to extract some informations.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Get File Type/Creator?
LC includes many features to read and convert elements in binary files. So with either form, I think you're onto something potentially quite useful for the OP there:
While most app publishers rarely use a different creator code for each version (if they use them at all anymore; Apple deprecated creator codes more than a decade ago), many apps rely on a "magic number" in the file's header to determine specifics about the file, such as perhaps the minimum app version it's compatible with.
If the OP can find info on whatever magic number scheme the app he wants to work with relies on, he may well be able to obtain the paths to the different app version on his hard drive and launch the one appropriate for a given document.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Get File Type/Creator?
Hi FourthWorld,
Thank you for the reply. I'd really like to try to build an app that would do this but I don't know to read the gibberish within an InDesign file when opened with a text editor (let alone how to tell LC how to interpret it)
Best regards,
Jon
Thank you for the reply. I'd really like to try to build an app that would do this but I don't know to read the gibberish within an InDesign file when opened with a text editor (let alone how to tell LC how to interpret it)
Best regards,
Jon
-
- VIP Livecode Opensource Backer
- Posts: 346
- Joined: Mon Mar 01, 2010 7:13 pm
- Location: London, UK
- Contact:
Re: Get File Type/Creator?
InDesign is probably the worst target app for this task – possibly for the same reason you want to do it!
InDesign documents will open whatever copy of InDesign is available, at which point (if the copy of InDesign is older than the one used to make the document, even by a tiny bit) the application will balk and complain mysteriously about "missing plugins." That's because, architecturally speaking, InDesign is basically a framework and a lot of plugins, and if any aren't available you're told so and the game stops. But that error message is stupendously unhelpful to almost all of humanity.
Anyway – I don't think an InDesign document contains any neat version code embedded in the header, just stuff that the app itself either understands or not. Sorry!
k
InDesign documents will open whatever copy of InDesign is available, at which point (if the copy of InDesign is older than the one used to make the document, even by a tiny bit) the application will balk and complain mysteriously about "missing plugins." That's because, architecturally speaking, InDesign is basically a framework and a lot of plugins, and if any aren't available you're told so and the game stops. But that error message is stupendously unhelpful to almost all of humanity.
Anyway – I don't think an InDesign document contains any neat version code embedded in the header, just stuff that the app itself either understands or not. Sorry!
k
Technical Writer, Meta
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Get File Type/Creator?
A quick search on Google for "InDesign file format specification" told me that it's a Zip file containing IDML, specified here:
http://wwwimages.adobe.com/content/dam/ ... cation.pdf
In LC we can open and read contents of Zip archives with the RevZip external. IDML is XML-based, which can be parsed with custom scripts or using LC's XML commands.
I think p44 of the PDF linked to above will get you where you need to go.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Get File Type/Creator?
Tip for lazy people (which definitely includes me, wherever possible): before going to the trouble of writing a set of routines to pull parts out of a Zip-based file, you can explore it easily enough by just add ".zip" to the file name. With that your file manager (Mac Finder, Windows Explorer, Gnome Nautilus) will just open it as any other Zip file. Then you can poke around easily, see what's there, and see if it's worth the trouble of proceeding to write something to automate getting parts out of it, such as with LC's Zip externals.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Get File Type/Creator?
Seconded by an even lazier person:) Good tip.FourthWorld wrote: ↑Tue Dec 05, 2017 10:09 pmTip for lazy people (which definitely includes me, wherever possible)
<sic>... just add ".zip" to the file name. With that your file manager (Mac Finder, Windows Explorer, Gnome Nautilus) will just open it as any other Zip file. Then you can poke around easily, see what's there, and see if it's worth the trouble of proceeding to write something to automate getting parts out of it, such as with LC's Zip externals.
Re: Get File Type/Creator?
I think I am getting closer to making this work however I've hit a snag that I don't understand. Using lessons from LC, this is the script I've pieced together:
on startup
local tFileName
put $1 into tFileName
loadFile tFileName
end startup
## We use an appleEvent to detect if the app was started by dragging a file onto it
on appleEvent pClass, pEventID, pSender
if pClass is "aevt" then
## This is an apple event
## We request the data about the apple event
request appleEvent data
put it into tFileName
if pEventID is "odoc" then
## This is an open document event
loadFile tFileName
end if
end if
pass appleEvent
end appleEvent
on loadFile pFileName
put URL ("file:" & pFileName) into field "Display"
if field "Display" contains "Adobe Indesign CS6" then
launch pFileName with "Adobe InDesign CS6.app"
else
answer "Not Found."
end if
--if field "Display" contains "Adobe InDesign CC 2017" then
--launch pFileName with "Adobe InDesign CC 2017.app"
--end if
--if field "Display" contains "Adobe InDesign CC 13.0" then
--launch pFileName with "Adobe InDesign CC 2018.app"
--end if
end loadFile
However, when I drag an InDesign CS6 file onto the compiled app (with the necessary CFBundleTypeExtension entry for an InDesign file), I get the "Not Found." dialog box but yet when the compiled app opens, I CAN find "Adobe InDesign CS6" in the "Display" field.
This will be a Mac-only application. What have I missed?
Thanks,
Jon
on startup
local tFileName
put $1 into tFileName
loadFile tFileName
end startup
## We use an appleEvent to detect if the app was started by dragging a file onto it
on appleEvent pClass, pEventID, pSender
if pClass is "aevt" then
## This is an apple event
## We request the data about the apple event
request appleEvent data
put it into tFileName
if pEventID is "odoc" then
## This is an open document event
loadFile tFileName
end if
end if
pass appleEvent
end appleEvent
on loadFile pFileName
put URL ("file:" & pFileName) into field "Display"
if field "Display" contains "Adobe Indesign CS6" then
launch pFileName with "Adobe InDesign CS6.app"
else
answer "Not Found."
end if
--if field "Display" contains "Adobe InDesign CC 2017" then
--launch pFileName with "Adobe InDesign CC 2017.app"
--end if
--if field "Display" contains "Adobe InDesign CC 13.0" then
--launch pFileName with "Adobe InDesign CC 2018.app"
--end if
end loadFile
However, when I drag an InDesign CS6 file onto the compiled app (with the necessary CFBundleTypeExtension entry for an InDesign file), I get the "Not Found." dialog box but yet when the compiled app opens, I CAN find "Adobe InDesign CS6" in the "Display" field.
This will be a Mac-only application. What have I missed?
Thanks,
Jon
Re: Get File Type/Creator?
Hi Jon,
I'm not sure, but I think at "startup" the app is ABOUT to get loaded,
so maybe not all GUI elements, libraries etc. are available yet!?
Try this:
Best
Klaus
I'm not sure, but I think at "startup" the app is ABOUT to get loaded,
so maybe not all GUI elements, libraries etc. are available yet!?
Try this:
Code: Select all
on startup
local tFileName
put $1 into tFileName
send "loadFile tFileName" to me in 30
## half a second delay to give the engine tome to laod everything
## Maybe a shorter delay will also work, do some testing :-)
end startup
Klaus
Re: Get File Type/Creator?
Hi Klaus,
I think you hit the nail on the head. Unfortunately, it seems that no matter what I do, I can't get the information to show in the field before the app checks the field for the particular text string (even if I extend the loadFile time to 5 seconds). Loading the URL into a variable instead of the text field did not work. I also tried replacing startUp with openStack which also did not work.
Here's the script as I currently have it. Any other ideas?
Thank you so much!
Jon
on startup
local tFileName
put $1 into tFileName
send "loadFile tFileName" to me in 60
end startup
## We use an appleEvent to detect if the app was started by dragging a file onto it
on appleEvent pClass, pEventID, pSender
if pClass is "aevt" then
## This is an apple event
## We request the data about the apple event
request appleEvent data
put it into tFileName
if pEventID is "odoc" then
## This is an open document event
send "loadFile tFileName" to me in 60
end if
end if
pass appleEvent
end appleEvent
on loadFile pFileName
put URL ("file:" & pFileName) into field "Display"
if field "Display" contains "Adobe Indesign CS6" then
launch pFileName with "Adobe InDesign CS6.app"
else
answer "Not Found."
end if
--if field "display" contains "Adobe InDesign CC 2017" then
--launch pFileName with "Adobe InDesign CC 2017.app"
--end if
--if field "display" contains "Adobe InDesign CC 13.0" then
--launch pFileName with "Adobe InDesign CC 2018.app"
--end if
end loadFile
I think you hit the nail on the head. Unfortunately, it seems that no matter what I do, I can't get the information to show in the field before the app checks the field for the particular text string (even if I extend the loadFile time to 5 seconds). Loading the URL into a variable instead of the text field did not work. I also tried replacing startUp with openStack which also did not work.
Here's the script as I currently have it. Any other ideas?
Thank you so much!
Jon
on startup
local tFileName
put $1 into tFileName
send "loadFile tFileName" to me in 60
end startup
## We use an appleEvent to detect if the app was started by dragging a file onto it
on appleEvent pClass, pEventID, pSender
if pClass is "aevt" then
## This is an apple event
## We request the data about the apple event
request appleEvent data
put it into tFileName
if pEventID is "odoc" then
## This is an open document event
send "loadFile tFileName" to me in 60
end if
end if
pass appleEvent
end appleEvent
on loadFile pFileName
put URL ("file:" & pFileName) into field "Display"
if field "Display" contains "Adobe Indesign CS6" then
launch pFileName with "Adobe InDesign CS6.app"
else
answer "Not Found."
end if
--if field "display" contains "Adobe InDesign CC 2017" then
--launch pFileName with "Adobe InDesign CC 2017.app"
--end if
--if field "display" contains "Adobe InDesign CC 13.0" then
--launch pFileName with "Adobe InDesign CC 2018.app"
--end if
end loadFile