本文介绍了将 MIMETYPE 文件设为 EPUB ZIP 文件中的第一个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是通过 AppleScript 创建一个 EPUB 文件,我从半手动生成一个 EPUB 文件开始.我的问题是 IDPF EPUB 验证器报告我的 MIMETYPE 文件不是我的 EPUB 包中的第一个文件,或者我的 MIMETYPE 不存在.我的 AppleScript 正在创建 EPUB 文件夹结构和 MIMETYPE 文件:

My goal is to create an EPUB file via an AppleScript, and I'm starting with semi-manually generating an EPUB file. My issue is that the IDPF EPUB validator reports that my MIMETYPE file isn't isn't the first file in my EPUB package or that my MIMETYPE doesn't exist. My AppleScript is creating the EPUB folder structure and a MIMETYPE file:

set EPUBMIMETYPEfilepath to ((EPUBfolderPath & ":MIMETYPE") as string)

set referenceToEPUBMIMETYPEfile to a reference to file EPUBMIMETYPEfilepath

open for access referenceToEPUBMIMETYPEfile with write permission

write "application/epub+zip" to referenceToEPUBMIMETYPEfile

close access referenceToEPUBMIMETYPEfile

因此,稍后当我拥有一组类似于标准 EPUB 结构的文件夹和文件时,我将使用命令行来压缩 EPUB:

So, later on when I have a collection of folders and files resembling a standard EPUB structure, I'm using the command line to ZIP up the EPUB:

zip -X0 ../epubFilename.epub MIMETYPE
zip -rDX9 ../epubFilename.epub.epub META-INF -x "*.DS_Store"
zip -rDX9 ../epubFilename.epub.epub OPS -x "*.DS_Store"

稍后我可以解压缩我的 EPUB 并实际看到其中确实有一个 MIMETYPE 文件,但可能不是第一个文件,因为 META-INF 文件夹是最先排序的?

Later on I can unzip my EPUB and actually see that there's indeed a MIMETYPE file within, however perhaps not the first file because the META-INF folder is sorted first?

问题:有人有在 Mac 上通过命令行创建 EPUB 的任何提示吗?

Question: does anyone have any tips to create an EPUB via the command line on a Mac?

推荐答案

正如您所发现的,mimetype 文件名必须是小写的.在 EPUB 格式所需的文件中,只有 META-INF/目录应具有大写名称.顺便说一下,您只需要一个 """zip -rDX9" 命令.-r 将递归地将子目录和文件包含到 .epub 中.

As you found out, the mimetype filename must be lowercase. Of the files required by the EPUB format, only the META-INF/ directory should have an uppercase name. By the way, you only need one """zip -rDX9" command. The -r will recursively include the subdirectories and files into the .epub.

这篇关于将 MIMETYPE 文件设为 EPUB ZIP 文件中的第一个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 08:17