Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Add the full format catalog: formats, donuts and presets
KnifeLemonfaa3dcd98de5
diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.jsonindex 728783c4..ca855ad4 100644--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@ -63,12 +63,21 @@"profile.presentations": "Presentations","profile.hwp": "HWP / HWPX","profile.text": "Text & Markdown",+ "profile.ebooks": "E-books",+ "profile.video": "Video",+ "profile.audio": "Audio",+ "profile.vector": "Vector graphics",+ "profile.archives": "Archives",+ "profile.cad": "CAD drawings",+ "profile.fonts": "Fonts","profile.mixed": "Mixed files","preset.half_size": "Half size","preset.grayscale": "Grayscale","preset.merge_pdf": "Merge PDF","preset.split_pdf": "Split PDF",+ "preset.extract": "Extract",+ "preset.zip_all": "One ZIP","general.title": "General","general.language": "Language",diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.jsonindex faa3ce0c..c45e8822 100644--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@ -63,12 +63,21 @@"profile.presentations": "프레젠테이션","profile.hwp": "HWP / HWPX","profile.text": "텍스트·마크다운",+ "profile.ebooks": "전자책",+ "profile.video": "동영상",+ "profile.audio": "오디오",+ "profile.vector": "벡터 그래픽",+ "profile.archives": "압축 파일",+ "profile.cad": "CAD 도면",+ "profile.fonts": "글꼴","profile.mixed": "혼합 파일","preset.half_size": "50% 축소","preset.grayscale": "흑백","preset.merge_pdf": "PDF 병합","preset.split_pdf": "PDF 분할",+ "preset.extract": "압축 풀기",+ "preset.zip_all": "ZIP 하나로","general.title": "일반","general.language": "언어",diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.jsonindex 0d581254..de9260d8 100644--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@ -63,12 +63,21 @@"profile.presentations": "演示文稿","profile.hwp": "HWP / HWPX","profile.text": "文本与 Markdown",+ "profile.ebooks": "电子书",+ "profile.video": "视频",+ "profile.audio": "音频",+ "profile.vector": "矢量图形",+ "profile.archives": "压缩文件",+ "profile.cad": "CAD 图纸",+ "profile.fonts": "字体","profile.mixed": "混合文件","preset.half_size": "缩小 50%","preset.grayscale": "灰度","preset.merge_pdf": "合并 PDF","preset.split_pdf": "拆分 PDF",+ "preset.extract": "解压",+ "preset.zip_all": "打包成一个 ZIP","general.title": "常规","general.language": "语言",diff --git a/src/Filee.App/ViewModels/PresetEditorViewModel.cs b/src/Filee.App/ViewModels/PresetEditorViewModel.csindex 20e9faa3..6ffca97f 100644--- a/src/Filee.App/ViewModels/PresetEditorViewModel.cs+++ b/src/Filee.App/ViewModels/PresetEditorViewModel.cs@@ -33,7 +33,7 @@ public sealed partial class PresetEditorViewModel : ObservableObject[new Choice<string>(BuiltInData.SameAsSource, loc["presets.same_as_source"]),.. FormatRegistry.Known- .Where(f => f.Id != "heic") // read-only format+ .Where(f => f.Writable).Select(f => new Choice<string>(f.Id, f.DisplayName)),];ResizeModes = Enum.GetValues<ResizeMode>().Select(v => new Choice<ResizeMode>(v, loc[$"presets.resize.{v}"])).ToList();diff --git a/src/Filee.Core/Conversion/IConverter.cs b/src/Filee.Core/Conversion/IConverter.csindex 4562895c..e5e32e1f 100644--- a/src/Filee.Core/Conversion/IConverter.cs+++ b/src/Filee.Core/Conversion/IConverter.cs@@ -32,7 +32,10 @@ public interface IOutputAllocator/// <summary>/// Returns the path the converter should write the next output file to./// </summary>- /// <param name="extension">Extension of the file being written, without dot.</param>+ /// <param name="extension">+ /// Extension of the file being written, without dot. Empty asks for a folder path (archive extraction); the+ /// converter creates the folder.+ /// </param>/// <param name="suffix">Optional name suffix such as <c>"_p2"</c> when one input produces several files.</param>/// <returns>A path, or <c>null</c> if this output must be skipped (existing file + "skip" policy).</returns>string? Allocate(string extension, string? suffix = null);diff --git a/src/Filee.Core/Conversion/JobQueue.cs b/src/Filee.Core/Conversion/JobQueue.csindex 7cd5146a..4922f28d 100644--- a/src/Filee.Core/Conversion/JobQueue.cs+++ b/src/Filee.Core/Conversion/JobQueue.cs@@ -141,7 +141,7 @@ public sealed class JobQueue : IAsyncDisposablevar ct = job.CancellationToken;var source = FormatRegistry.Detect(file.SourcePath);if (source is null)- return Fail(file, "error.unsupported_source", Path.GetExtension(file.SourcePath));+ return Fail(file, "error.unsupported_source", "." + FormatRegistry.ExtensionOf(file.SourcePath));var target = !finalOutput ? "pdf": job.Preset.TargetFormat == BuiltInData.SameAsSource ? source.Id@@ -163,7 +163,7 @@ public sealed class JobQueue : IAsyncDisposablevar isLast = s == route.Steps.Count - 1;IOutputAllocator allocator = isLast && finalOutput? CreateFinalAllocator(job, file.SourcePath, index)- : new TempAllocator(workDir, Path.GetFileNameWithoutExtension(file.SourcePath));+ : new TempAllocator(workDir, FormatRegistry.NameWithoutExtension(file.SourcePath));var outputs = new List<string>();foreach (var input in inputs)@@ -288,12 +288,13 @@ public sealed class JobQueue : IAsyncDisposablelock (queue._reservedOutputs){var path = OutputPathResolver.Resolve(rule, tokens, extension,- p => File.Exists(p) || queue._reservedOutputs.Contains(p), suffix);+ p => File.Exists(p) || Directory.Exists(p) || queue._reservedOutputs.Contains(p), suffix);if (path is null)return null;queue._reservedOutputs.Add(path);Directory.CreateDirectory(Path.GetDirectoryName(path)!);+ // An empty extension asks for a folder (archive extraction): the converter creates it.return path;}}@@ -306,7 +307,8 @@ public sealed class JobQueue : IAsyncDisposable{var dir = Path.Combine(workDir, Guid.NewGuid().ToString("N")[..8]);Directory.CreateDirectory(dir);- return Path.Combine(dir, $"{baseName}{suffix}.{extension.TrimStart('.')}");+ var ext = extension.TrimStart('.');+ return Path.Combine(dir, ext.Length == 0 ? $"{baseName}{suffix}" : $"{baseName}{suffix}.{ext}");}}}diff --git a/src/Filee.Core/Formats/FileFormat.cs b/src/Filee.Core/Formats/FileFormat.csindex 1396ed51..c8049d3d 100644--- a/src/Filee.Core/Formats/FileFormat.cs+++ b/src/Filee.Core/Formats/FileFormat.cs@@ -12,6 +12,13 @@ public enum FormatCategoryPresentation,Hwp,Text,+ Video,+ Audio,+ Ebook,+ Archive,+ Vector,+ Cad,+ Font,}/// <summary>@@ -20,8 +27,12 @@ public enum FormatCategory/// <param name="Id">Stable lower-case identifier used in presets and converter edges (e.g. <c>"jpg"</c>).</param>/// <param name="DisplayName">Short label shown in the UI (e.g. <c>"JPG"</c>).</param>/// <param name="Category">Format family.</param>-/// <param name="Extensions">File extensions without the dot; the first one is used for output files.</param>-public sealed record FileFormat(string Id, string DisplayName, FormatCategory Category, IReadOnlyList<string> Extensions)+/// <param name="Extensions">+/// File extensions without the dot; the first one is used for output files. Compound extensions such as+/// <c>"tar.gz"</c> are allowed.+/// </param>+/// <param name="Writable">False for formats Filee only reads (camera RAW, Apple Pages, ...): not offered as a target.</param>+public sealed record FileFormat(string Id, string DisplayName, FormatCategory Category, IReadOnlyList<string> Extensions, bool Writable = true){/// <summary>Extension (without dot) used when writing a file of this format.</summary>public string PrimaryExtension => Extensions[0];diff --git a/src/Filee.Core/Formats/FormatRegistry.cs b/src/Filee.Core/Formats/FormatRegistry.csindex 0e83e153..31ac1b0c 100644--- a/src/Filee.Core/Formats/FormatRegistry.cs+++ b/src/Filee.Core/Formats/FormatRegistry.cs@@ -6,6 +6,9 @@ namespace Filee.Core.Formats;/// <summary>Lookup table of every format Filee knows about.</summary>public static class FormatRegistry{+ /// <summary>Pseudo format of the "Extract" preset: the output is a folder with the archive's files.</summary>+ public const string Folder = "folder";+/// <summary>All known formats. Order is the order shown in format pickers.</summary>public static IReadOnlyList<FileFormat> Known { get; } =[@@ -18,16 +21,54 @@ public static class FormatRegistrynew("gif", "GIF", FormatCategory.Image, ["gif"]),new("ico", "ICO", FormatCategory.Image, ["ico"]),new("avif", "AVIF", FormatCategory.Image, ["avif"]),- new("heic", "HEIC", FormatCategory.Image, ["heic", "heif"]),+ new("heic", "HEIC", FormatCategory.Image, ["heic", "heif"], Writable: false),+ new("jxl", "JPEG XL", FormatCategory.Image, ["jxl"]),+ new("jp2", "JPEG 2000", FormatCategory.Image, ["jp2", "j2k", "jpf", "jpx"]),+ new("psd", "PSD", FormatCategory.Image, ["psd"]),+ new("psb", "PSB", FormatCategory.Image, ["psb"]),+ new("tga", "TGA", FormatCategory.Image, ["tga", "icb", "vda", "vst"]),+ new("ppm", "PPM", FormatCategory.Image, ["ppm", "pgm", "pbm", "pnm"]),+ new("icns", "ICNS", FormatCategory.Image, ["icns"]),+ new("xcf", "XCF", FormatCategory.Image, ["xcf"], Writable: false),+ new("raw", "RAW", FormatCategory.Image,+ ["dng", "cr2", "cr3", "crw", "nef", "nrw", "arw", "srf", "sr2", "orf", "rw2", "raf", "pef", "dcr", "kdc",+ "erf", "mos", "mrw", "x3f", "3fr", "fff", "iiq", "mef", "rwl", "srw", "raw"], Writable: false),++ // Vector graphics+ new("svg", "SVG", FormatCategory.Vector, ["svg"]),+ new("svgz", "SVGZ", FormatCategory.Vector, ["svgz"]),+ new("eps", "EPS", FormatCategory.Vector, ["eps", "epsf", "epsi"]),+ new("ps", "PS", FormatCategory.Vector, ["ps"]),+ new("ai", "AI", FormatCategory.Vector, ["ai"], Writable: false),+ new("emf", "EMF", FormatCategory.Vector, ["emf"]),+ new("wmf", "WMF", FormatCategory.Vector, ["wmf"]),+ new("cdr", "CDR", FormatCategory.Vector, ["cdr"], Writable: false),+ new("cgm", "CGM", FormatCategory.Vector, ["cgm"], Writable: false),+ new("vsd", "VSD", FormatCategory.Vector, ["vsd", "vsdx"], Writable: false),+ new("odg", "ODG", FormatCategory.Vector, ["odg"]),new("pdf", "PDF", FormatCategory.Pdf, ["pdf"]),// Word processingnew("docx", "DOCX", FormatCategory.Document, ["docx"]),+ new("docm", "DOCM", FormatCategory.Document, ["docm"]),+ new("dotx", "DOTX", FormatCategory.Document, ["dotx"]),+ new("dotm", "DOTM", FormatCategory.Document, ["dotm"]),new("doc", "DOC", FormatCategory.Document, ["doc"]),+ new("dot", "DOT", FormatCategory.Document, ["dot"], Writable: false),new("odt", "ODT", FormatCategory.Document, ["odt"]),new("rtf", "RTF", FormatCategory.Document, ["rtf"]),+ new("wps", "WPS", FormatCategory.Document, ["wps"], Writable: false),+ new("wpd", "WPD", FormatCategory.Document, ["wpd"], Writable: false),+ new("lwp", "LWP", FormatCategory.Document, ["lwp"], Writable: false),+ new("abw", "ABW", FormatCategory.Document, ["abw", "zabw"], Writable: false),+ new("pages", "Pages", FormatCategory.Document, ["pages"], Writable: false),+ new("sdw", "SDW", FormatCategory.Document, ["sdw"], Writable: false),+ new("pub", "PUB", FormatCategory.Document, ["pub"], Writable: false),+ new("xps", "XPS", FormatCategory.Document, ["xps", "oxps"], Writable: false),+ new("djvu", "DjVu", FormatCategory.Document, ["djvu", "djv"], Writable: false),+ new("eml", "EML", FormatCategory.Document, ["eml"], Writable: false),// Korean word processor (Hancom)new("hwpx", "HWPX", FormatCategory.Hwp, ["hwpx"]),@@ -35,28 +76,160 @@ public static class FormatRegistry// Spreadsheetsnew("xlsx", "XLSX", FormatCategory.Spreadsheet, ["xlsx"]),- new("xls", "XLS", FormatCategory.Spreadsheet, ["xls"]),+ new("xlsm", "XLSM", FormatCategory.Spreadsheet, ["xlsm"]),+ new("xltx", "XLTX", FormatCategory.Spreadsheet, ["xltx"]),+ new("xls", "XLS", FormatCategory.Spreadsheet, ["xls", "xlt"]),new("ods", "ODS", FormatCategory.Spreadsheet, ["ods"]),new("csv", "CSV", FormatCategory.Spreadsheet, ["csv"]),+ new("tsv", "TSV", FormatCategory.Spreadsheet, ["tsv", "tab"]),+ new("et", "ET", FormatCategory.Spreadsheet, ["et"], Writable: false),+ new("numbers", "Numbers", FormatCategory.Spreadsheet, ["numbers"], Writable: false),+ new("sdc", "SDC", FormatCategory.Spreadsheet, ["sdc"], Writable: false),// Presentationsnew("pptx", "PPTX", FormatCategory.Presentation, ["pptx"]),- new("ppt", "PPT", FormatCategory.Presentation, ["ppt"]),+ new("pptm", "PPTM", FormatCategory.Presentation, ["pptm"]),+ new("potx", "POTX", FormatCategory.Presentation, ["potx"]),+ new("ppsx", "PPSX", FormatCategory.Presentation, ["ppsx"]),+ new("ppt", "PPT", FormatCategory.Presentation, ["ppt", "pps", "pot"]),new("odp", "ODP", FormatCategory.Presentation, ["odp"]),+ new("key", "Keynote", FormatCategory.Presentation, ["key"], Writable: false),+ new("dps", "DPS", FormatCategory.Presentation, ["dps"], Writable: false),+ new("sda", "SDA", FormatCategory.Presentation, ["sda", "sdd"], Writable: false),// Plain text / markupnew("txt", "TXT", FormatCategory.Text, ["txt"]),new("md", "Markdown", FormatCategory.Text, ["md", "markdown"]),- new("html", "HTML", FormatCategory.Text, ["html", "htm"]),+ new("html", "HTML", FormatCategory.Text, ["html", "htm", "xhtml"]),+ new("rst", "reStructuredText", FormatCategory.Text, ["rst"]),+ new("tex", "LaTeX", FormatCategory.Text, ["tex", "latex"]),++ // E-books+ new("epub", "EPUB", FormatCategory.Ebook, ["epub"]),+ new("mobi", "MOBI", FormatCategory.Ebook, ["mobi"]),+ new("azw3", "AZW3", FormatCategory.Ebook, ["azw3"]),+ new("azw", "AZW", FormatCategory.Ebook, ["azw"], Writable: false),+ new("azw4", "AZW4", FormatCategory.Ebook, ["azw4"], Writable: false),+ new("prc", "PRC", FormatCategory.Ebook, ["prc"], Writable: false),+ new("fb2", "FB2", FormatCategory.Ebook, ["fb2"]),+ new("cbz", "CBZ", FormatCategory.Ebook, ["cbz"]),+ new("cbr", "CBR", FormatCategory.Ebook, ["cbr"], Writable: false),+ new("cb7", "CB7", FormatCategory.Ebook, ["cb7"], Writable: false),+ new("cbt", "CBT", FormatCategory.Ebook, ["cbt"], Writable: false),+ new("cbc", "CBC", FormatCategory.Ebook, ["cbc"], Writable: false),+ new("htmlz", "HTMLZ", FormatCategory.Ebook, ["htmlz"]),+ new("txtz", "TXTZ", FormatCategory.Ebook, ["txtz"]),+ new("chm", "CHM", FormatCategory.Ebook, ["chm"], Writable: false),+ new("lit", "LIT", FormatCategory.Ebook, ["lit"]),+ new("lrf", "LRF", FormatCategory.Ebook, ["lrf"]),+ new("pdb", "PDB", FormatCategory.Ebook, ["pdb"]),+ new("pml", "PML", FormatCategory.Ebook, ["pml"]),+ new("rb", "RB", FormatCategory.Ebook, ["rb"]),+ new("snb", "SNB", FormatCategory.Ebook, ["snb"]),+ new("tcr", "TCR", FormatCategory.Ebook, ["tcr"]),+ new("oeb", "OEB", FormatCategory.Ebook, ["oeb", "opf"], Writable: false),++ // Video+ new("mp4", "MP4", FormatCategory.Video, ["mp4"]),+ new("m4v", "M4V", FormatCategory.Video, ["m4v"]),+ new("mov", "MOV", FormatCategory.Video, ["mov", "qt"]),+ new("mkv", "MKV", FormatCategory.Video, ["mkv"]),+ new("webm", "WEBM", FormatCategory.Video, ["webm"]),+ new("avi", "AVI", FormatCategory.Video, ["avi", "divx"]),+ new("wmv", "WMV", FormatCategory.Video, ["wmv", "asf"]),+ new("flv", "FLV", FormatCategory.Video, ["flv", "f4v"]),+ new("mpg", "MPEG", FormatCategory.Video, ["mpg", "mpeg", "mpe", "m1v", "m2v"]),+ new("ts", "TS", FormatCategory.Video, ["ts"]),+ new("m2ts", "M2TS", FormatCategory.Video, ["m2ts", "mts", "m2t"]),+ new("3gp", "3GP", FormatCategory.Video, ["3gp", "3gpp"]),+ new("3g2", "3G2", FormatCategory.Video, ["3g2"]),+ new("ogv", "OGV", FormatCategory.Video, ["ogv"]),+ new("vob", "VOB", FormatCategory.Video, ["vob"]),+ new("mod", "MOD", FormatCategory.Video, ["mod", "tod"], Writable: false),+ new("dv", "DV", FormatCategory.Video, ["dv", "dif"]),+ new("mxf", "MXF", FormatCategory.Video, ["mxf"]),+ new("rm", "RM", FormatCategory.Video, ["rm", "rmvb"], Writable: false),+ new("swf", "SWF", FormatCategory.Video, ["swf"], Writable: false),+ new("wtv", "WTV", FormatCategory.Video, ["wtv", "dvr-ms", "dvr"], Writable: false),+ new("cavs", "CAVS", FormatCategory.Video, ["cavs"], Writable: false),++ // Audio+ new("mp3", "MP3", FormatCategory.Audio, ["mp3"]),+ new("m4a", "M4A", FormatCategory.Audio, ["m4a"]),+ new("m4b", "M4B", FormatCategory.Audio, ["m4b"]),+ new("aac", "AAC", FormatCategory.Audio, ["aac"]),+ new("wav", "WAV", FormatCategory.Audio, ["wav", "wave"]),+ new("flac", "FLAC", FormatCategory.Audio, ["flac"]),+ new("ogg", "OGG", FormatCategory.Audio, ["ogg", "oga"]),+ new("opus", "OPUS", FormatCategory.Audio, ["opus"]),+ new("wma", "WMA", FormatCategory.Audio, ["wma"]),+ new("aiff", "AIFF", FormatCategory.Audio, ["aiff", "aif", "aifc"]),+ new("ac3", "AC3", FormatCategory.Audio, ["ac3"]),+ new("amr", "AMR", FormatCategory.Audio, ["amr"]),+ new("au", "AU", FormatCategory.Audio, ["au", "snd"]),+ new("caf", "CAF", FormatCategory.Audio, ["caf"]),+ new("weba", "WEBA", FormatCategory.Audio, ["weba"]),+ new("mka", "MKA", FormatCategory.Audio, ["mka"]),+ new("mp2", "MP2", FormatCategory.Audio, ["mp2", "mpa"]),+ new("dss", "DSS", FormatCategory.Audio, ["dss"], Writable: false),+ new("voc", "VOC", FormatCategory.Audio, ["voc"]),++ // Archives+ new("zip", "ZIP", FormatCategory.Archive, ["zip"]),+ new("7z", "7Z", FormatCategory.Archive, ["7z"]),+ new("rar", "RAR", FormatCategory.Archive, ["rar"], Writable: false),+ new("tar", "TAR", FormatCategory.Archive, ["tar"]),+ new("tgz", "TAR.GZ", FormatCategory.Archive, ["tar.gz", "tgz", "taz"]),+ new("tbz2", "TAR.BZ2", FormatCategory.Archive, ["tar.bz2", "tbz2", "tar.bz", "tbz"]),+ new("txz", "TAR.XZ", FormatCategory.Archive, ["tar.xz", "txz"]),+ new("tar7z", "TAR.7Z", FormatCategory.Archive, ["tar.7z"], Writable: false),+ new("tlz", "TAR.LZ", FormatCategory.Archive, ["tar.lz", "tlz"], Writable: false),+ new("tzo", "TAR.LZO", FormatCategory.Archive, ["tar.lzo", "tzo"], Writable: false),+ new("tz", "TAR.Z", FormatCategory.Archive, ["tar.z", "tz"], Writable: false),+ new("gz", "GZ", FormatCategory.Archive, ["gz"]),+ new("bz2", "BZ2", FormatCategory.Archive, ["bz2", "bz"]),+ new("xz", "XZ", FormatCategory.Archive, ["xz"]),+ new("lz", "LZ", FormatCategory.Archive, ["lz"], Writable: false),+ new("lzma", "LZMA", FormatCategory.Archive, ["lzma"], Writable: false),+ new("lzo", "LZO", FormatCategory.Archive, ["lzo"], Writable: false),+ new("z", "Z", FormatCategory.Archive, ["z"], Writable: false),+ new("jar", "JAR", FormatCategory.Archive, ["jar"], Writable: false),+ new("cab", "CAB", FormatCategory.Archive, ["cab"], Writable: false),+ new("cpio", "CPIO", FormatCategory.Archive, ["cpio"], Writable: false),+ new("deb", "DEB", FormatCategory.Archive, ["deb"], Writable: false),+ new("rpm", "RPM", FormatCategory.Archive, ["rpm"], Writable: false),+ new("dmg", "DMG", FormatCategory.Archive, ["dmg"], Writable: false),+ new("iso", "ISO", FormatCategory.Archive, ["iso"], Writable: false),+ new("img", "IMG", FormatCategory.Archive, ["img"], Writable: false),+ new("lha", "LHA", FormatCategory.Archive, ["lha", "lzh"], Writable: false),+ new("arj", "ARJ", FormatCategory.Archive, ["arj"], Writable: false),+ new("alz", "ALZ", FormatCategory.Archive, ["alz"], Writable: false),+ new("egg", "EGG", FormatCategory.Archive, ["egg"], Writable: false),+ new(Folder, "Folder", FormatCategory.Archive, [""]),++ // CAD+ new("dwg", "DWG", FormatCategory.Cad, ["dwg"]),+ new("dxf", "DXF", FormatCategory.Cad, ["dxf"]),++ // Fonts+ new("ttf", "TTF", FormatCategory.Font, ["ttf"]),+ new("otf", "OTF", FormatCategory.Font, ["otf"]),+ new("woff", "WOFF", FormatCategory.Font, ["woff"]),+ new("woff2", "WOFF2", FormatCategory.Font, ["woff2"]),+ new("eot", "EOT", FormatCategory.Font, ["eot"]),];private static readonly Dictionary<string, FileFormat> ById =Known.ToDictionary(f => f.Id, StringComparer.OrdinalIgnoreCase);private static readonly Dictionary<string, FileFormat> ByExtension =- Known.SelectMany(f => f.Extensions.Select(e => (e, f)))+ Known.SelectMany(f => f.Extensions.Where(e => e.Length > 0).Select(e => (e, f))).ToDictionary(x => x.e, x => x.f, StringComparer.OrdinalIgnoreCase);+ /// <summary>Extensions made of two parts ("tar.gz"), checked before the last part alone.</summary>+ private static readonly string[] CompoundExtensions =+ ByExtension.Keys.Where(e => e.Contains('.')).OrderByDescending(e => e.Length).ToArray();+/// <summary>Returns the format with the given id, or <c>null</c>.</summary>public static FileFormat? FindById(string id) => ById.GetValueOrDefault(id);@@ -66,8 +239,32 @@ public static class FormatRegistry/// <summary>Returns the format for an extension (with or without the leading dot), or <c>null</c>.</summary>public static FileFormat? FindByExtension(string extension) =>- ByExtension.GetValueOrDefault(extension.TrimStart('.'));+ extension.TrimStart('.') is { Length: > 0 } ext ? ByExtension.GetValueOrDefault(ext) : null;/// <summary>Detects the format of a file from its extension, or <c>null</c> if it is not supported.</summary>- public static FileFormat? Detect(string path) => FindByExtension(Path.GetExtension(path));+ public static FileFormat? Detect(string path) => FindByExtension(ExtensionOf(path));++ /// <summary>+ /// The extension of <paramref name="path"/> without the dot, including known two-part extensions+ /// ("archive.tar.gz" → "tar.gz", "photo.jpg" → "jpg").+ /// </summary>+ public static string ExtensionOf(string path)+ {+ var name = Path.GetFileName(path);+ foreach (var compound in CompoundExtensions)+ {+ if (name.Length > compound.Length + 1+ && name.EndsWith("." + compound, StringComparison.OrdinalIgnoreCase))+ return name[^compound.Length..];+ }+ return Path.GetExtension(name).TrimStart('.');+ }++ /// <summary>The file name without its (possibly two-part) extension: "backup.tar.gz" → "backup".</summary>+ public static string NameWithoutExtension(string path)+ {+ var name = Path.GetFileName(path);+ var extension = ExtensionOf(name);+ return extension.Length == 0 ? name : name[..^(extension.Length + 1)];+ }}diff --git a/src/Filee.Core/Presets/BuiltInData.cs b/src/Filee.Core/Presets/BuiltInData.csindex e8a53f83..6f0584f7 100644--- a/src/Filee.Core/Presets/BuiltInData.cs+++ b/src/Filee.Core/Presets/BuiltInData.cs@@ -1,5 +1,6 @@// Factory defaults: presets and toolbar profiles created on first run or "Reset to defaults".+using Filee.Core.Formats;using Filee.Core.Profiles;namespace Filee.Core.Presets;@@ -60,6 +61,7 @@ public static class BuiltInDatanew() { Id = "to-md", Name = "Markdown", TargetFormat = "md" },new() { Id = "to-html", Name = "HTML", TargetFormat = "html" },.. SpreadsheetPresets(),+ .. CatalogPresets(),];/// <summary>Spreadsheet targets (added in settings schema 5, see SettingsMigrations).</summary>@@ -69,26 +71,102 @@ public static class BuiltInDatanew() { Id = "to-csv", Name = "CSV", TargetFormat = "csv" },];+ /// <summary>+ /// Targets of the formats added in settings schema 6: images, vector, office, e-books, video, audio, archives,+ /// CAD and fonts (see SettingsMigrations).+ /// </summary>+ public static List<Preset> CatalogPresets() =>+ [+ // Images and vector graphics+ new() { Id = "to-jxl", Name = "JPEG XL", TargetFormat = "jxl", Image = { Quality = 85 } },+ new() { Id = "to-psd", Name = "PSD", TargetFormat = "psd" },+ new() { Id = "to-tga", Name = "TGA", TargetFormat = "tga" },+ new() { Id = "to-icns", Name = "ICNS", TargetFormat = "icns" },+ new() { Id = "to-svg", Name = "SVG", TargetFormat = "svg" },+ new() { Id = "to-eps", Name = "EPS", TargetFormat = "eps" },++ // Office and text+ new() { Id = "to-ods", Name = "ODS", TargetFormat = "ods" },+ new() { Id = "to-pptx", Name = "PPTX", TargetFormat = "pptx" },+ new() { Id = "to-odp", Name = "ODP", TargetFormat = "odp" },++ // E-books+ new() { Id = "to-epub", Name = "EPUB", TargetFormat = "epub" },+ new() { Id = "to-mobi", Name = "MOBI", TargetFormat = "mobi" },+ new() { Id = "to-azw3", Name = "AZW3", TargetFormat = "azw3" },+ new() { Id = "to-fb2", Name = "FB2", TargetFormat = "fb2" },+ new() { Id = "to-cbz", Name = "CBZ", TargetFormat = "cbz" },++ // Video+ new() { Id = "to-mp4", Name = "MP4", TargetFormat = "mp4" },+ new()+ {+ Id = "mp4-720", Name = "MP4 720p", TargetFormat = "mp4",+ Media = { MaxHeight = 720, Quality = MediaQuality.Small }, Output = { FileNamePattern = "{name}_720p" },+ },+ new() { Id = "to-webm", Name = "WEBM", TargetFormat = "webm" },+ new() { Id = "to-mov", Name = "MOV", TargetFormat = "mov" },+ new() { Id = "to-mkv", Name = "MKV", TargetFormat = "mkv" },+ new() { Id = "to-avi", Name = "AVI", TargetFormat = "avi" },++ // Audio+ new() { Id = "to-mp3", Name = "MP3", TargetFormat = "mp3" },+ new()+ {+ Id = "mp3-128", Name = "MP3 128k", TargetFormat = "mp3",+ Media = { AudioBitrateKbps = 128 }, Output = { FileNamePattern = "{name}_128k" },+ },+ new() { Id = "to-m4a", Name = "M4A", TargetFormat = "m4a" },+ new() { Id = "to-wav", Name = "WAV", TargetFormat = "wav" },+ new() { Id = "to-flac", Name = "FLAC", TargetFormat = "flac" },+ new() { Id = "to-ogg", Name = "OGG", TargetFormat = "ogg" },+ new() { Id = "to-opus", Name = "OPUS", TargetFormat = "opus" },+ new() { Id = "to-aac", Name = "AAC", TargetFormat = "aac" },++ // Archives+ new() { Id = "to-zip", Name = "ZIP", TargetFormat = "zip" },+ new() { Id = "to-7z", Name = "7Z", TargetFormat = "7z" },+ new() { Id = "to-tgz", Name = "TAR.GZ", TargetFormat = "tgz" },+ new() { Id = "to-tar", Name = "TAR", TargetFormat = "tar" },+ new() { Id = "extract", NameKey = "preset.extract", TargetFormat = FormatRegistry.Folder },+ new()+ {+ Id = "zip-all", NameKey = "preset.zip_all", TargetFormat = "zip",+ Archive = { CombineIntoOne = true }, Output = { FileNamePattern = "{name}_files" },+ },++ // CAD+ new() { Id = "to-dxf", Name = "DXF", TargetFormat = "dxf" },+ new() { Id = "to-dwg", Name = "DWG", TargetFormat = "dwg" },++ // Fonts+ new() { Id = "to-ttf", Name = "TTF", TargetFormat = "ttf" },+ new() { Id = "to-otf", Name = "OTF", TargetFormat = "otf" },+ new() { Id = "to-woff", Name = "WOFF", TargetFormat = "woff" },+ new() { Id = "to-woff2", Name = "WOFF2", TargetFormat = "woff2" },+ new() { Id = "to-eot", Name = "EOT", TargetFormat = "eot" },+ ];+/// <summary>Creates the default toolbar profiles.</summary>public static List<ToolbarProfile> CreateProfiles() =>[new(){Id = "images", NameKey = "profile.images",- Extensions = ["png", "jpg", "jpeg", "jpe", "jfif", "webp", "tiff", "tif", "bmp", "dib", "gif", "ico", "avif", "heic", "heif"],+ Extensions = ExtensionsOf(FormatCategory.Image),PresetIds = ["to-png", "to-jpg", "to-webp", "to-pdf", "to-tiff", "to-bmp", "to-ico", "half-size"],},new(){Id = "pdf", NameKey = "profile.pdf",Extensions = ["pdf"],- PresetIds = ["to-png", "to-jpg", "to-tiff", "pdf-split", "merge-pdf"],+ PresetIds = ["to-png", "to-jpg", "to-docx", "to-txt", "to-hwpx", "to-tiff", "pdf-split", "merge-pdf"],},new(){Id = "office", NameKey = "profile.office",- Extensions = ["docx", "doc", "odt", "rtf"],- PresetIds = ["to-pdf", "to-hwpx", "to-docx", "to-odt", "to-txt", "to-html", "merge-pdf"],+ Extensions = ExtensionsOf(FormatCategory.Document),+ PresetIds = ["to-pdf", "to-hwpx", "to-docx", "to-odt", "to-txt", "to-html", "to-epub", "merge-pdf"],},SpreadsheetProfile(),PresentationProfile(),@@ -99,10 +177,11 @@ public static class BuiltInDataPresetIds = ["to-pdf", "to-docx", "to-hwpx", "to-png", "to-txt", "to-md", "merge-pdf"],},TextProfile(),+ .. CatalogProfiles(),new(){Id = "mixed", NameKey = "profile.mixed", IsFallback = true,- PresetIds = ["to-pdf", "merge-pdf", "to-png", "to-txt"],+ PresetIds = ["to-pdf", "merge-pdf", "zip-all", "to-png", "to-txt"],},];@@ -111,8 +190,8 @@ public static class BuiltInData{Id = "spreadsheets",NameKey = "profile.spreadsheets",- Extensions = ["xlsx", "xls", "ods", "csv"],- PresetIds = ["to-pdf", "to-xlsx", "to-csv", "to-hwpx", "to-html", "merge-pdf"],+ Extensions = ExtensionsOf(FormatCategory.Spreadsheet),+ PresetIds = ["to-pdf", "to-xlsx", "to-csv", "to-ods", "to-hwpx", "to-html", "merge-pdf"],};/// <summary>PowerPoint and OpenDocument slides (split from "office" in settings schema 5).</summary>@@ -120,8 +199,8 @@ public static class BuiltInData{Id = "presentations",NameKey = "profile.presentations",- Extensions = ["pptx", "ppt", "odp"],- PresetIds = ["to-pdf", "to-png", "to-jpg", "to-hwpx", "merge-pdf"],+ Extensions = ExtensionsOf(FormatCategory.Presentation),+ PresetIds = ["to-pdf", "to-png", "to-jpg", "to-pptx", "to-hwpx", "merge-pdf"],};/// <summary>Markdown, plain text and HTML (added in settings schema 4, see SettingsMigrations).</summary>@@ -129,7 +208,61 @@ public static class BuiltInData{Id = "text",NameKey = "profile.text",- Extensions = ["md", "markdown", "txt", "html", "htm"],- PresetIds = ["to-pdf", "to-hwpx", "to-docx", "to-html", "to-txt"],+ Extensions = ExtensionsOf(FormatCategory.Text),+ PresetIds = ["to-pdf", "to-hwpx", "to-docx", "to-html", "to-txt", "to-epub"],};++ /// <summary>Donuts of the categories added in settings schema 6, in the order they follow "text".</summary>+ public static List<ToolbarProfile> CatalogProfiles() =>+ [+ new()+ {+ Id = "ebooks", NameKey = "profile.ebooks",+ Extensions = ExtensionsOf(FormatCategory.Ebook),+ PresetIds = ["to-pdf", "to-epub", "to-docx", "to-txt", "to-azw3", "to-mobi", "to-hwpx", "to-html"],+ },+ new()+ {+ Id = "video", NameKey = "profile.video",+ Extensions = ExtensionsOf(FormatCategory.Video),+ PresetIds = ["to-mp4", "mp4-720", "to-webm", "to-mov", "to-gif", "to-mp3", "to-mkv", "to-avi"],+ },+ new()+ {+ Id = "audio", NameKey = "profile.audio",+ Extensions = ExtensionsOf(FormatCategory.Audio),+ PresetIds = ["to-mp3", "mp3-128", "to-m4a", "to-wav", "to-flac", "to-ogg", "to-opus", "to-aac"],+ },+ new()+ {+ Id = "vector", NameKey = "profile.vector",+ Extensions = ExtensionsOf(FormatCategory.Vector),+ PresetIds = ["to-png", "to-pdf", "to-svg", "to-jpg", "to-webp", "to-eps"],+ },+ new()+ {+ Id = "archives", NameKey = "profile.archives",+ Extensions = ExtensionsOf(FormatCategory.Archive),+ PresetIds = ["extract", "to-zip", "to-7z", "to-tgz", "to-tar"],+ },+ new()+ {+ Id = "cad", NameKey = "profile.cad",+ Extensions = ExtensionsOf(FormatCategory.Cad),+ PresetIds = ["to-pdf", "to-png", "to-svg", "to-dxf", "to-dwg"],+ },+ new()+ {+ Id = "fonts", NameKey = "profile.fonts",+ Extensions = ExtensionsOf(FormatCategory.Font),+ PresetIds = ["to-woff2", "to-woff", "to-ttf", "to-otf", "to-eot"],+ },+ ];++ /// <summary>Every file extension of the formats in <paramref name="category"/>.</summary>+ public static List<string> ExtensionsOf(FormatCategory category) =>+ FormatRegistry.Known.Where(f => f.Category == category)+ .SelectMany(f => f.Extensions)+ .Where(e => e.Length > 0)+ .ToList();}diff --git a/src/Filee.Core/Presets/OutputPathResolver.cs b/src/Filee.Core/Presets/OutputPathResolver.csindex 39ca7e98..dc74a49a 100644--- a/src/Filee.Core/Presets/OutputPathResolver.cs+++ b/src/Filee.Core/Presets/OutputPathResolver.cs@@ -1,6 +1,7 @@// Turns an OutputRule + source file into the concrete output path. Pure logic, unit tested.using System.Text;+using Filee.Core.Formats;namespace Filee.Core.Presets;@@ -15,7 +16,7 @@ public static class OutputPathResolver/// </summary>/// <param name="rule">Placement rule of the preset.</param>/// <param name="tokens">Token values for the file name pattern.</param>- /// <param name="targetExtension">Extension of the output, without dot.</param>+ /// <param name="targetExtension">Extension of the output, without dot; empty for a folder (archive extraction).</param>/// <param name="exists">Returns true if a path is already taken (on disk or reserved by this batch).</param>/// <param name="suffix">Optional suffix appended to the name, e.g. <c>"_p3"</c> for page 3.</param>/// <returns>The path to write, or <c>null</c> when the rule says to skip an existing file.</returns>@@ -30,10 +31,11 @@ public static class OutputPathResolver_ => sourceDir,};- var sourceName = Path.GetFileNameWithoutExtension(tokens.SourcePath);+ var sourceName = FormatRegistry.NameWithoutExtension(tokens.SourcePath);var name = Sanitize(ExpandPattern(rule.FileNamePattern, tokens), sourceName) + suffix;var ext = targetExtension.TrimStart('.');- var candidate = Path.Combine(dir, $"{name}.{ext}");+ string PathFor(string baseName) => Path.Combine(dir, ext.Length == 0 ? baseName : $"{baseName}.{ext}");+ var candidate = PathFor(name);// The source file is never overwritten, whatever the policy says.var isSource = PathsEqual(candidate, tokens.SourcePath);@@ -47,7 +49,7 @@ public static class OutputPathResolverfor (var n = 2; ; n++){- candidate = Path.Combine(dir, $"{name} ({n}).{ext}");+ candidate = PathFor($"{name} ({n})");if (!exists(candidate) && !PathsEqual(candidate, tokens.SourcePath))return candidate;}@@ -59,9 +61,9 @@ public static class OutputPathResolverif (string.IsNullOrWhiteSpace(pattern))pattern = "{name}";- var ext = Path.GetExtension(tokens.SourcePath).TrimStart('.');+ var ext = FormatRegistry.ExtensionOf(tokens.SourcePath);return pattern- .Replace("{name}", Path.GetFileNameWithoutExtension(tokens.SourcePath), StringComparison.OrdinalIgnoreCase)+ .Replace("{name}", FormatRegistry.NameWithoutExtension(tokens.SourcePath), StringComparison.OrdinalIgnoreCase).Replace("{ext}", ext, StringComparison.OrdinalIgnoreCase).Replace("{preset}", tokens.PresetName, StringComparison.OrdinalIgnoreCase).Replace("{date}", tokens.Now.ToString("yyyyMMdd"), StringComparison.OrdinalIgnoreCase)diff --git a/src/Filee.Core/Presets/Preset.cs b/src/Filee.Core/Presets/Preset.csindex 2b031622..f58287bf 100644--- a/src/Filee.Core/Presets/Preset.cs+++ b/src/Filee.Core/Presets/Preset.cs@@ -32,6 +32,12 @@ public sealed class Preset/// <summary>Options used for office / HWP documents.</summary>public DocumentOptions Document { get; set; } = new();+ /// <summary>Options used for video and audio.</summary>+ public MediaOptions Media { get; set; } = new();++ /// <summary>Options used for archives (ZIP, 7Z, TAR ...).</summary>+ public ArchiveOptions Archive { get; set; } = new();+/// <summary>Where and how output files are written.</summary>public OutputRule Output { get; set; } = new();@@ -48,6 +54,8 @@ public sealed class PresetImage = Image.Clone(),Pdf = Pdf.Clone(),Document = Document.Clone(),+ Media = Media.Clone(),+ Archive = Archive.Clone(),Output = Output.Clone(),};}@@ -153,3 +161,52 @@ public sealed class DocumentOptionspublic DocumentOptions Clone() => (DocumentOptions)MemberwiseClone();}++/// <summary>Trade-off between quality and file size for video and lossy audio.</summary>+public enum MediaQuality+{+ /// <summary>Visually lossless, large files.</summary>+ High,+ /// <summary>Good quality at a reasonable size (default).</summary>+ Balanced,+ /// <summary>Small files for sharing, visible compression.</summary>+ Small,+}++/// <summary>Video and audio options.</summary>+public sealed class MediaOptions+{+ public MediaQuality Quality { get; set; } = MediaQuality.Balanced;++ /// <summary>Largest output height in pixels (e.g. 720); 0 keeps the source size. Never upscales.</summary>+ public int MaxHeight { get; set; }++ /// <summary>Audio bitrate in kbit/s for lossy audio; 0 uses a good default for the format.</summary>+ public int AudioBitrateKbps { get; set; }++ /// <summary>Drop the audio track of a video.</summary>+ public bool RemoveAudio { get; set; }++ public MediaOptions Clone() => (MediaOptions)MemberwiseClone();+}++/// <summary>How hard archives are compressed.</summary>+public enum ArchiveLevel+{+ /// <summary>No compression (fast, for already compressed files).</summary>+ Store,+ Fast,+ Normal,+ Maximum,+}++/// <summary>Archive options.</summary>+public sealed class ArchiveOptions+{+ /// <summary>Put all dropped files into one archive instead of one archive per file.</summary>+ public bool CombineIntoOne { get; set; }++ public ArchiveLevel Level { get; set; } = ArchiveLevel.Normal;++ public ArchiveOptions Clone() => (ArchiveOptions)MemberwiseClone();+}diff --git a/src/Filee.Core/Profiles/ToolbarProfile.cs b/src/Filee.Core/Profiles/ToolbarProfile.csindex c2a27e15..da5764e9 100644--- a/src/Filee.Core/Profiles/ToolbarProfile.cs+++ b/src/Filee.Core/Profiles/ToolbarProfile.cs@@ -56,7 +56,7 @@ public static class ProfileSelectorpublic static ToolbarProfile? Select(IReadOnlyList<ToolbarProfile> profiles, IEnumerable<string> filePaths){var extensions = filePaths- .Select(p => Path.GetExtension(p).TrimStart('.'))+ .Select(FormatRegistry.ExtensionOf).Distinct(StringComparer.OrdinalIgnoreCase).ToList();diff --git a/src/Filee.Core/Settings/AppSettings.cs b/src/Filee.Core/Settings/AppSettings.csindex 2cfb645d..06547816 100644--- a/src/Filee.Core/Settings/AppSettings.cs+++ b/src/Filee.Core/Settings/AppSettings.cs@@ -48,7 +48,7 @@ public sealed class DonutSettingspublic sealed class AppSettings{/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>- public const int CurrentSchemaVersion = 5;+ public const int CurrentSchemaVersion = 6;public int SchemaVersion { get; set; } = CurrentSchemaVersion;@@ -78,7 +78,11 @@ public sealed class AppSettingspublic List<string> ExcludedProcesses { get; set; } = [];/// <summary>Engine ids in preferred order (see <see cref="Conversion.ConverterCatalog.Priority"/>).</summary>- public List<string> EnginePriority { get; set; } = ["magick", "pdfium", "pdfsharp", "rhwp", "unhwp", "markdown", "spreadsheet", "hwpx-writer", "pandoc", "libreoffice"];+ public List<string> EnginePriority { get; set; } =+ [+ "magick", "pdfium", "pdfsharp", "rhwp", "unhwp", "markdown", "spreadsheet", "ooxml", "hwpx-writer", "docx-writer",+ "vector", "icns", "font", "cad", "archive", "ebook", "ffmpeg", "pandoc", "ghostscript", "calibre", "libreoffice",+ ];/// <summary>Set once the first-run welcome has been shown.</summary>public bool FirstRunCompleted { get; set; }diff --git a/src/Filee.Core/Settings/UserDataStore.cs b/src/Filee.Core/Settings/UserDataStore.csindex cfc41477..129e1500 100644--- a/src/Filee.Core/Settings/UserDataStore.cs+++ b/src/Filee.Core/Settings/UserDataStore.cs@@ -239,6 +239,17 @@ internal static class SettingsMigrationsInsertBefore(settings.EnginePriority, "spreadsheet", "hwpx-writer");}+ // v6: engines for the rest of the format catalog. Built-in ones go before Pandoc, optional downloads+ // before LibreOffice (the fallback that stays last).+ if (settings.SchemaVersion < 6)+ {+ InsertBefore(settings.EnginePriority, "ooxml", "hwpx-writer");+ foreach (var id in new[] { "docx-writer", "vector", "icns", "font", "cad", "archive", "ebook", "ffmpeg" })+ InsertBefore(settings.EnginePriority, id, "pandoc");+ foreach (var id in new[] { "ghostscript", "calibre" })+ InsertBefore(settings.EnginePriority, id, "libreoffice");+ }+if (settings.Triggers.Count == 0)settings.Triggers = TriggerGesture.Defaults();@@ -293,6 +304,63 @@ internal static class SettingsMigrationsif (profiles.FirstOrDefault(p => p.Id == "pdf") is { } pdf)changed |= pdf.PresetIds.RemoveAll(id => id is "to-docx" or "to-hwpx" or "to-txt") > 0;}++ // v6: the rest of the format catalog (video, audio, e-books, archives, vector, CAD, fonts, more image and+ // office formats). Built-in donuts learn their new extensions unless another donut already has them, the+ // new donuts follow "text", PDF → DOCX is back on the PDF donut (built in now) and the mixed-files donut+ // gets "compress into one ZIP".+ if (from < 6)+ changed |= AddCatalog(presets, profiles);+ return changed;+ }++ private static bool AddCatalog(List<Preset> presets, List<ToolbarProfile> profiles)+ {+ var changed = false;+ foreach (var preset in BuiltInData.CatalogPresets().Where(p => presets.All(existing => existing.Id != p.Id)))+ {+ presets.Add(preset);+ changed = true;+ }+ var presetIds = presets.Select(p => p.Id).ToHashSet();++ var claimed = profiles.SelectMany(p => p.Extensions).ToHashSet(StringComparer.OrdinalIgnoreCase);+ var defaults = BuiltInData.CreateProfiles().ToDictionary(p => p.Id);+ foreach (var profile in profiles.Where(p => !p.IsFallback && defaults.ContainsKey(p.Id)))+ {+ foreach (var extension in defaults[profile.Id].Extensions.Where(claimed.Add))+ {+ profile.Extensions.Add(extension);+ changed = true;+ }+ }++ var text = profiles.FindIndex(p => p.Id == "text");+ var insertAt = text >= 0 ? text + 1 : profiles.FindIndex(p => p.IsFallback);+ insertAt = insertAt < 0 ? profiles.Count : insertAt;+ foreach (var profile in BuiltInData.CatalogProfiles().Where(p => profiles.All(existing => existing.Id != p.Id)))+ {+ // Only the extensions no donut of the user takes yet.+ profile.Extensions = profile.Extensions.Where(claimed.Add).ToList();+ if (profile.Extensions.Count == 0)+ continue;+ profile.PresetIds = profile.PresetIds.Where(presetIds.Contains).ToList();+ profiles.Insert(insertAt++, profile);+ changed = true;+ }++ void Offer(string profileId, string presetId, string? after)+ {+ if (profiles.FirstOrDefault(p => p.Id == profileId) is not { } profile+ || profile.PresetIds.Contains(presetId) || profile.PresetIds.Count >= ToolbarProfile.MaxSlices+ || !presetIds.Contains(presetId))+ return;+ var index = after is null ? -1 : profile.PresetIds.IndexOf(after);+ profile.PresetIds.Insert(index < 0 ? profile.PresetIds.Count : index + 1, presetId);+ changed = true;+ }+ Offer("pdf", "to-docx", "to-jpg");+ Offer(profiles.FirstOrDefault(p => p.IsFallback)?.Id ?? "mixed", "zip-all", "merge-pdf");return changed;}diff --git a/tests/Filee.Core.Tests/OutputPathResolverTests.cs b/tests/Filee.Core.Tests/OutputPathResolverTests.csindex 2675df42..5003156e 100644--- a/tests/Filee.Core.Tests/OutputPathResolverTests.cs+++ b/tests/Filee.Core.Tests/OutputPathResolverTests.cs@@ -1,3 +1,4 @@+using Filee.Core.Formats;using Filee.Core.Presets;namespace Filee.Core.Tests;@@ -19,6 +20,35 @@ public class OutputPathResolverTestsAssert.Equal(Path.Combine(dir.Path, "photo.png"), path);}+ [Fact]+ public void Two_part_extensions_are_one_extension()+ {+ using var dir = new TempDir();+ var source = dir.File("backup.tar.gz");++ var path = OutputPathResolver.Resolve(new OutputRule(), Tokens(source), "zip", File.Exists);++ Assert.Equal(Path.Combine(dir.Path, "backup.zip"), path);+ Assert.Equal("tgz", FormatRegistry.Detect(source)!.Id);+ Assert.Equal("tar.gz", FormatRegistry.ExtensionOf(source));+ Assert.Equal("gz", FormatRegistry.ExtensionOf("notes.txt.gz"));+ Assert.Equal("notes.txt", FormatRegistry.NameWithoutExtension("notes.txt.gz"));+ Assert.Equal("mp4", FormatRegistry.Detect("clip.MP4")!.Id);+ Assert.Null(FormatRegistry.Detect("README"));+ }++ [Fact]+ public void An_empty_extension_asks_for_a_folder()+ {+ using var dir = new TempDir();+ var source = dir.File("photos.zip");+ Directory.CreateDirectory(Path.Combine(dir.Path, "photos"));++ var path = OutputPathResolver.Resolve(new OutputRule(), Tokens(source), "", p => File.Exists(p) || Directory.Exists(p));++ Assert.Equal(Path.Combine(dir.Path, "photos (2)"), path);+ }+[Fact]public void Existing_file_gets_a_number_by_default(){diff --git a/tests/Filee.Core.Tests/UserDataStoreTests.cs b/tests/Filee.Core.Tests/UserDataStoreTests.csindex 742bece3..8c8c81e1 100644--- a/tests/Filee.Core.Tests/UserDataStoreTests.cs+++ b/tests/Filee.Core.Tests/UserDataStoreTests.cs@@ -40,7 +40,7 @@ public class UserDataStoreTestsvar store = new UserDataStore(dir.Path);store.Load();- Assert.Equal(["magick", "markdown", "spreadsheet", "hwpx-writer", "pandoc", "libreoffice"], store.Settings.EnginePriority);+ Assert.Equal(["magick", "markdown", "spreadsheet", "ooxml", "hwpx-writer", "docx-writer", "vector", "icns", "font", "cad", "archive", "ebook", "ffmpeg", "pandoc", "ghostscript", "calibre", "libreoffice"], store.Settings.EnginePriority);Assert.Equal(AppSettings.CurrentSchemaVersion, store.Settings.SchemaVersion);}@@ -92,14 +92,43 @@ public class UserDataStoreTestsvar store = new UserDataStore(dir.Path);store.Load();- Assert.Equal(["magick", "markdown", "spreadsheet", "hwpx-writer", "pandoc", "libreoffice"], store.Settings.EnginePriority);+ Assert.Equal(["magick", "markdown", "spreadsheet", "ooxml", "hwpx-writer", "docx-writer", "vector", "icns", "font", "cad", "archive", "ebook", "ffmpeg", "pandoc", "ghostscript", "calibre", "libreoffice"], store.Settings.EnginePriority);var ids = store.Profiles.Select(p => p.Id).ToList();Assert.Equal(ids.IndexOf("office") + 1, ids.IndexOf("spreadsheets"));Assert.Equal(ids.IndexOf("office") + 2, ids.IndexOf("presentations"));Assert.DoesNotContain("xlsx", store.Profiles.Single(p => p.Id == "office").Extensions);Assert.Contains("to-csv", store.Profiles.Single(p => p.Id == "spreadsheets").PresetIds);Assert.NotNull(store.FindPreset("to-xlsx"));- Assert.DoesNotContain("to-docx", store.Profiles.Single(p => p.Id == "pdf").PresetIds);+ Assert.DoesNotContain("to-hwpx", store.Profiles.Single(p => p.Id == "pdf").PresetIds); // Word-only target removed by v5+ }++ [Fact]+ public void Version_5_libraries_get_the_format_catalog()+ {+ // As written by 1.0.x with schema 5: no catalog presets, donuts or extensions.+ var presets = BuiltInData.CreatePresets().Where(p => BuiltInData.CatalogPresets().All(c => c.Id != p.Id)).ToList();+ var catalogIds = BuiltInData.CatalogProfiles().Select(p => p.Id).ToHashSet();+ var profiles = BuiltInData.CreateProfiles().Where(p => !catalogIds.Contains(p.Id)).ToList();+ profiles.Single(p => p.Id == "images").Extensions = ["png", "jpg"];+ profiles.Single(p => p.Id == "pdf").PresetIds.Remove("to-docx");+ profiles.Single(p => p.Id == "mixed").PresetIds.Remove("zip-all");+ // A donut of the user already handles MP3.+ profiles.Insert(0, new ToolbarProfile { Id = "mine", Name = "Mine", Extensions = ["mp3"] });++ Assert.True(SettingsMigrations.ApplyToLibrary(5, presets, profiles));++ var ids = profiles.Select(p => p.Id).ToList();+ Assert.Equal(ids.IndexOf("text") + 1, ids.IndexOf("ebooks"));+ Assert.Equal(ids.IndexOf("mixed") - 1, ids.IndexOf("fonts"));+ Assert.Contains("cr2", profiles.Single(p => p.Id == "images").Extensions);+ Assert.DoesNotContain("mp3", profiles.Single(p => p.Id == "audio").Extensions);+ Assert.Contains("flac", profiles.Single(p => p.Id == "audio").Extensions);+ Assert.Contains(presets, p => p.Id == "to-mp4");+ Assert.Equal(["to-png", "to-jpg", "to-docx"], profiles.Single(p => p.Id == "pdf").PresetIds.Take(3));+ Assert.Contains("zip-all", profiles.Single(p => p.Id == "mixed").PresetIds);+ // Every extension belongs to one donut only.+ var all = profiles.SelectMany(p => p.Extensions).ToList();+ Assert.Equal(all.Count, all.Distinct(StringComparer.OrdinalIgnoreCase).Count());}[Fact]@@ -121,7 +150,7 @@ public class UserDataStoreTestsvar profiles = BuiltInData.CreateProfiles().Where(p => p.Id != "text").ToList();profiles[0].Extensions.Add("md");- Assert.False(SettingsMigrations.ApplyToLibrary(3, BuiltInData.CreatePresets(), profiles));+ SettingsMigrations.ApplyToLibrary(3, BuiltInData.CreatePresets(), profiles);Assert.DoesNotContain(profiles, p => p.Id == "text");}