-
1. Re: ZIP-package from indesign (by script)
Dirk Becker Jun 20, 2011 12:26 PM (in response to Petteri_Paananen)The application object has the very intuitively named methods packageUCF and unpackageUCF, intended to handle IDML files which themselves are ZIP.
Dirk
-
2. Re: ZIP-package from indesign (by script)
Harbs. Jun 20, 2011 12:41 PM (in response to Dirk Becker)IIRC, there were issues using those methods to create zips (most specifically with image files).
This might be useful:
-
3. Re: ZIP-package from indesign (by script)
Petteri_Paananen Jun 20, 2011 1:20 PM (in response to Harbs.)Thanks for the answers!
Harbs, have you ever used that jszip with indesign? I found references to web-browsers only.... do you think it could be possible to use that for compressing bunch of JPG image files as ZIP?
-
4. Re: ZIP-package from indesign (by script)
[Jongware] Jun 20, 2011 1:52 PM (in response to Petteri_Paananen)Does it matter JPEGs cannot be compressed very well? If all of this is just to get a single package of files, then I'm tempted to do the PNG trick once more and attempt to create a ZIP file that contains uncompressed files only ...
-
5. Re: ZIP-package from indesign (by script)
Marc Autret Jun 20, 2011 6:01 PM (in response to Petteri_Paananen)JsZip is not very fast when 'wrapped' in ExtendScript, but it works.
I think you only have to patch File / Folder access…
Just found this old piece of code in my drawers:
#include 'jszip/jszip.js' JSZip.prototype.addExistingFile = function(/*File*/f, newName) { var contents = false; if( f.constructor == File && f.exists && (f.encoding = 'BINARY') && f.open('r') ) { contents = f.read(); f.close(); return this.add(newName||f.name, contents, {binary: true, date:f.modified}); } throw new Error("Unable to open the file "+f); } // SAMPLE CODE /* var folder = app.activeScript.parent; var zip = new JSZip(); zip.add("Hello.txt", "Hello World\n"); zip.folder("images"). addExistingFile(File(folder+"/test.jpg")); var content = zip.generate(true); // asBytes var f = File(folder+'/test.zip'); f.encoding = 'BINARY'; if( f.open('w') ) { f.write(content); f.close(); } */Hope that helps.
@+
Marc
-
6. Re: ZIP-package from indesign (by script)
John Hawkinson Jun 20, 2011 8:15 PM (in response to Petteri_Paananen)What OS? I really think you are much better off calling out to the operating system's zip utility. This is tricky under windows and trivial under Mac OS.
-
7. Re: ZIP-package from indesign (by script)
Petteri_Paananen Jun 20, 2011 10:48 PM (in response to John Hawkinson)Thanks to everyone, specially Marc for the code sample...
This ZIP-thing is not for the compressing the size, it´s more for easing up the next face of the workflow. It´s much more nicer to handle only one file instead of hundreds of them....=)
Script is actually made by Marijan "Tomaxxi" Tompa so I probably ask him if he had time to give this a try at some point..... this is not a busy case....
@John, I thought using OS too, but I try to keep this whole solution as OS independent as possible, so if there is any deasent generic solution I rather test it first. If it´s too slow or there are some other flaws, I´ll consider using OS based compression methods.....
-
8. Re: ZIP-package from indesign (by script)
Dirk Becker Jun 20, 2011 11:07 PM (in response to Harbs.)Harbs,
could you please clarify - were the images distorted somehow or was it just suboptimal compression (file size) as Jongware indicates?
Thanks,
Dirk
-
9. Re: ZIP-package from indesign (by script)
Harbs. Jun 20, 2011 11:48 PM (in response to Dirk Becker)Dirk,
I just checked my archives and found what I was remembering.
Teus de Jong (OBM) had tried to use it for packaging ePubs and it failed for that purpose. Fonts and images were missing data.
Harbs
-
10. Re: ZIP-package from indesign (by script)
Loic_aigon Jun 21, 2011 4:09 AM (in response to Harbs.)I agree with John, zip system mechanism do that very well. I am quite sure code has been already been given for both platforms here :).
-
11. Re: ZIP-package from indesign (by script)
Philippe Ruelle Feb 28, 2012 1:21 PM (in response to Petteri_Paananen)Good evening,
I can not use the script (on Mac) it gives me a syntax error ... but at first I want to open a used function without ".docx" "app.unpackageUCF () and app.packageUCF ()".
thank youBonsoir,
Je ne parvient pas à utilisé le script (sur Mac) il me donne une erreur de syntaxe... mais dans un premièr temps je veux ouvrir un ".docx" sans utilisé les fonction "app.unpackageUCF() and app.packageUCF()".
Merci
-
12. Re: ZIP-package from indesign (by script)
John Hawkinson Feb 28, 2012 1:25 PM (in response to Philippe Ruelle)Philippe, you know your avatar image is stretched, right? You might want to fix that.
This script cannot and should not work on a Mac.
But on a Mac it is much much easier. Just use
app.doScript('do shell script "zip filename.zip file1 file2 file3"', ScriptLanguage.APPLECRIPT_LANGUAGE);
I cannot understand what you are saying about packageUCF().
-
13. Re: ZIP-package from indesign (by script)
Philippe Ruelle Feb 28, 2012 1:45 PM (in response to Petteri_Paananen)if I'm not saying error!
This function is two "app.unpackageUCF () and app.packageUCF ()" are passed by indesign me and I do not want.
for the command line with Toolkit, it returns me the error "app.doscript is not a function".
To open the docs, I guess I use the command "UNZIP".thank you
PhilippeC'est deux fonction "app.unpackageUCF() et app.packageUCF()" me font passé par indesign et je ne veux pas.
pour la ligne de commande avec Toolkit, il me retourne l'erreur "app.doscript n'est pas une fonction".
Pour ouvrir le docs, je suppose que j'utilise la commande "UNZIP".
Merci
Philippe
-
14. Re: ZIP-package from indesign (by script)
John Hawkinson Feb 28, 2012 2:14 PM (in response to Philippe Ruelle)I am having great difficulty understanding you.
app.doScript is not the same as app.doscript. The 'S' is capitalized.
-
15. Re: ZIP-package from indesign (by script)
Philippe Ruelle Feb 29, 2012 4:25 AM (in response to Petteri_Paananen)Hello and thank you
Is it possible to have an example that fonctione?
PhilippeBonjour et merci
Est-il possible d'avoir un exemple qui fonctione?
Philippe
-
16. Re: ZIP-package from indesign (by script)
Philippe Ruelle Feb 29, 2012 1:53 PM (in response to Petteri_Paananen)var test = app.doScript('do shell script "zip ~/Desktop/Zip/test3.zip ~/Desktop/Zip/test7/" ', ScriptLanguage.applescriptLanguage);
this command gives me this result as:
#target indesign
var test = app.doScript('do shell script "zip ~/Desktop/Zip/test3.zip RS125_96B.pdf V8_Engine_Overhaul_Manual.pdf" ', ScriptLanguage.applescriptLanguage);
this command gives me a file.
var test = app.doScript('do shell script "zip ~/Desktop/Zip/test3.zip test7/*.pdf" ', ScriptLanguage.applescriptLanguage);
this command does:
and to extract the archive it is even harder (unzip). -
17. Re: ZIP-package from indesign (by script)
Philippe Ruelle Mar 1, 2012 12:31 PM (in response to Petteri_Paananen)Good evening or good morning
The command app.doScript () function does not free the code "# target indesign" or set of ESKT indesign??
I want to do a standalone script!
Thank you ...Bonsoir ou bonjour
La commande app.doScript() ne fonction pas sans le code " #target indesign" ou réglé ESKT sur indesign???
Je veux faire un script autonome !
Merci ...
-
18. Re: ZIP-package from indesign (by script)
John Hawkinson Mar 2, 2012 4:13 PM (in response to Philippe Ruelle)I'm sorry, Philippe, I'm still having a lot of difficulty understanding you.
Maybe you could try to find someone who is a native speaker of English?
Thanks, and sorry about that.
-
19. Re: ZIP-package from indesign (by script)
sstanleyau Mar 2, 2012 7:48 PM (in response to John Hawkinson)John Hawkinson wrote:
app.doScript('do shell script "zip filename.zip file1 file2 file3"', ScriptLanguage.APPLECRIPT_LANGUAGE);
FWIW, ditto is a better choice than zip for Mac stuff.
-
20. Re: ZIP-package from indesign (by script)
John Hawkinson Mar 2, 2012 8:01 PM (in response to sstanleyau)FWIW, ditto is a better choice than zip for Mac stuff.
Gosh, that's an interesting question, Shane!
From a portability perspective, that's untrue, at least from my background.
zip works across all Unix systems, and even works under Windows if you have Cygwin or whatnot.
ditto is Mac-specific.
But you're right, ditto has signicant features that zip does not. Specifically it supports resource forks and and HFS metadata.
But ditto also has annoying command-line syntax do that. Is it truly neccesary to use "ditto -c -k --sequesterRsrc --keepParent srcdir srcdir.zip"?
In fairness, I guess one has to use "zip -r srcdir.zip srcdir" but it still seems a lot cleaner.
Ah well.
I guess I would use zip just for simplicity, but I see why others might disagree.
-
21. Re: ZIP-package from indesign (by script)
Muppet Mark Mar 3, 2012 1:53 AM (in response to John Hawkinson)John, I also use ditto for zip and have done for some time… Never caused me any problems… Horses for courses…
-
22. Re: ZIP-package from indesign (by script)
John Hawkinson Mar 3, 2012 8:05 AM (in response to Muppet Mark)Wha-huh? Mark, nobody said ditto caused anyone problems. It's just a Mac-only tool with a complex command-line syntax that is extremely verbose.
-
23. Re: ZIP-package from indesign (by script)
Philippe Ruelle Mar 3, 2012 10:05 AM (in response to Petteri_Paananen)Hello
Ditto with, is it possible to exclude *. DS_Store.
thank you
Bonjour
Avec ditto, est-il possible exclure les *.DS_Store.
Merci
-
24. Re: ZIP-package from indesign (by script)
John Hawkinson Mar 3, 2012 12:33 PM (in response to Philippe Ruelle)Phillipe asks:
Ditto with, is it possible to exclude *. DS_Store.
No. With ditto, it is not possible to exclude files or directories.
You could copy the directory first with "cp" and remove the .DS_Store file.
You could delete the .DS_Store file for the zip archive using zip -d.
Or you could simply create the zip file using zip.
-
25. Re: ZIP-package from indesign (by script)
Philippe Ruelle Mar 4, 2012 1:29 AM (in response to Petteri_Paananen)Hello,
The ultimate goal set to open a IDML, modify and close without open Indesign.
PhilippeBonjour,
Le but final set de pouvoir ouvrir un idml, le modifier et le refermer sans avoir Indesign ouvert.
Philippe
-
26. Re: ZIP-package from indesign (by script)
[Jongware] Mar 4, 2012 5:25 AM (in response to Philippe Ruelle)Philippe Ruelle wrote:
The ultimate goal set to open a IDML, modify and close without open Indesign.
If this script still needs to run inside InDesign, that would be rather pointless
Oh let's have Google Translate a go at this as well: "Si ce script doit encore courir à l'intérieur d'InDesign, ce serait plutôt inutile " (Don't you trust your own English? At times I have to revert to your original in French to have it make sense!)
-
27. Re: ZIP-package from indesign (by script)
Philippe Ruelle Mar 4, 2012 7:00 AM (in response to Petteri_Paananen)I want to change or create database files (the sound of txt)
But also a docx file conversion to IDML or Adobe InDesign tagged text ...
I'll cross that I travailier faster in Perl.thank youGoogle translation. -
28. Re: ZIP-package from indesign (by script)
sstanleyau Mar 4, 2012 4:22 PM (in response to John Hawkinson)John Hawkinson wrote:
FWIW, ditto is a better choice than zip for Mac stuff.
Gosh, that's an interesting question, Shane!
From a portability perspective, that's untrue, at least from my background.
zip works across all Unix systems, and even works under Windows if you have Cygwin or whatnot.
ditto is Mac-specific.
Which is why I said "for Mac stuff". Your script included ScriptLanguage.APPLECRIPT_LANGUAGE, so I assumed that was a given.
The syntax is verbose, but it essentially lets you match what using the Finder's Compress command does. zip's syntax is simpler, but then you have to manually organize things like a wrapper folder, and so on.
-
29. Re: ZIP-package from indesign (by script)
John Hawkinson Mar 4, 2012 4:43 PM (in response to sstanleyau)Which is why I said "for Mac stuff". Your script included ScriptLanguage.APPLECRIPT_LANGUAGE, so I assumed that was a given.
Well, I'm living in a fantasy world where "portability" doesn't mean "Windows and Mac" it means "Linux, Solaris (umm), Unix, etc."
You're free to argue this is completely unreasaonble since InDesign won't be running on any such platforms any time soon.
The syntax is verbose, but it essentially lets you match what using the Finder's Compress command does. zip's syntax is simpler, but then you have to manually organize things like a wrapper folder, and so on.
Sure. Though if Philippe is really just editing IDML, this is all academic.
-
30. Re: ZIP-package from indesign (by script)
s_ashok Jun 6, 2014 12:14 AM (in response to Marc Autret)JsZip
Hi,
if the script is working in windows.
Do u have the jszip script for windows.
Thanks in advance.
Regards
Ashok







