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
Folders given with a trailing separator are named like the folder everywhere
KnifeLemon0bf812af0bdf
diff --git a/src/Filee.App/Services/DraggedFiles.cs b/src/Filee.App/Services/DraggedFiles.csindex aba233a4..aedd701f 100644--- a/src/Filee.App/Services/DraggedFiles.cs+++ b/src/Filee.App/Services/DraggedFiles.cs@@ -21,10 +21,7 @@ internal static class DraggedFiles/// leave them out. A trailing separator is removed, and a drive or the file system root is ignored./// </summary>public static IReadOnlyList<string> Local(IDataTransfer data) =>- Local(data, IsFileOrFolder, AppHost.Get<IPlatformServices>().ResolveShortcuts);-- /// <summary>Whether <paramref name="path"/> is a file or a folder that exists.</summary>- internal static bool IsFileOrFolder(string path) => File.Exists(path) || Directory.Exists(path);+ Local(data, ConversionService.Exists, AppHost.Get<IPlatformServices>().ResolveShortcuts);internal static IReadOnlyList<string> Local(IDataTransfer data, Func<string, bool> exists,Func<IReadOnlyList<string>, IReadOnlyList<string>>? resolveShortcuts = null)diff --git a/src/Filee.App/Services/PresetAvailability.cs b/src/Filee.App/Services/PresetAvailability.csindex 742786eb..96206811 100644--- a/src/Filee.App/Services/PresetAvailability.cs+++ b/src/Filee.App/Services/PresetAvailability.cs@@ -16,11 +16,10 @@ public sealed class PresetAvailability(ConverterCatalog catalog, ILocalizer loc,public string? Check(Preset preset, IReadOnlyList<FileFormat> formats){// "Compress into one archive" packs the files as they are, so any file works, even of an unknown type.- if (preset.Archive.CombineIntoOne- && FormatRegistry.FindById(preset.TargetFormat) is { Category: FormatCategory.Archive } archive- && archive.Id != FormatRegistry.Folder)+ if (preset.PacksIntoOneArchive){- return catalog.All.OfType<IFileCombiner>().Any(c => c.CanCombineInto(archive.Id)) ? null : loc["error.no_route"];+ var archive = FormatRegistry.Get(preset.TargetFormat).Id;+ return catalog.All.OfType<IFileCombiner>().Any(c => c.CanCombineInto(archive)) ? null : loc["error.no_route"];}if (formats.Count == 0)diff --git a/src/Filee.App/Services/RadialController.cs b/src/Filee.App/Services/RadialController.csindex 97f996be..ca202c54 100644--- a/src/Filee.App/Services/RadialController.cs+++ b/src/Filee.App/Services/RadialController.cs@@ -19,6 +19,7 @@ using Filee.App.ViewModels;using Filee.App.Views;using Filee.Core.Conversion;using Filee.Core.Platform;+using Filee.Core.Presets;using Filee.Core.Profiles;using Filee.Core.Settings;using Microsoft.Extensions.Logging;@@ -265,18 +266,14 @@ public sealed class RadialController(/// <summary>Converts with slice <paramref name="index"/>, or with slice <paramref name="sub"/> of that group's ring.</summary>private void Convert(int index, int sub, IReadOnlyList<string> files){- var preset = viewModel.PresetAt(index, sub);- // Folders only go into "Compress into one archive"; any other preset converts the files beside them (#186).- if (preset is { PacksIntoOneArchive: false })- files = files.Where(path => !Directory.Exists(path)).ToList();- if (preset is null || files.Count == 0)+ if (viewModel.PresetAt(index, sub) is not { } preset || SourcesFor(preset, files) is not { Count: > 0 } sources){Close();return;}- log.LogInformation("Converting {Count} file(s) with preset {Preset}", files.Count, preset.Id);- var job = conversions.Start(files, preset, showInToast: false);+ log.LogInformation("Converting {Count} file(s) with preset {Preset}", sources.Count, preset.Id);+ var job = conversions.Start(sources, preset, showInToast: false);if (job is null || _window is null){Close();@@ -286,6 +283,13 @@ public sealed class RadialController(ShowProgress(job);}+ /// <summary>+ /// What <paramref name="preset"/> converts of <paramref name="files"/>: folders only go into "Compress into one+ /// archive"; any other preset converts the files beside them (issue #186).+ /// </summary>+ internal static IReadOnlyList<string> SourcesFor(Preset preset, IReadOnlyList<string> files) =>+ preset.PacksIntoOneArchive ? files : [.. files.Where(path => !Directory.Exists(path))];+// ───────── Progress ring ─────────private void ShowProgress(JobViewModel job)diff --git a/src/Filee.Core/Conversion/JobQueue.cs b/src/Filee.Core/Conversion/JobQueue.csindex 03aa3dc0..bb5858bc 100644--- a/src/Filee.Core/Conversion/JobQueue.cs+++ b/src/Filee.Core/Conversion/JobQueue.cs@@ -88,10 +88,7 @@ public sealed class JobQueue : IAsyncDisposable&& job.Files.Count > 1&& _pdfMerger is not null;// Any files, one of them or many, archives or not: they go into the archive as they are.- var combine = job.Preset.Archive.CombineIntoOne- && _combiner is not null- && FormatRegistry.FindById(job.Preset.TargetFormat) is { Category: FormatCategory.Archive } archive- && archive.Id != FormatRegistry.Folder;+ var combine = job.Preset.PacksIntoOneArchive && _combiner is not null;// One file is enough: a 10-page PDF becomes one 10-page TIFF.var multiPageTiff = job.Preset.Image.MultiPageTiff && job.Preset.TargetFormat == "tiff" && _tiffMerger is not null;@@ -234,7 +231,7 @@ public sealed class JobQueue : IAsyncDisposablevar inputs = new List<FileResult>();foreach (var file in job.Files){- // Folders (from the command line; drops deliver files) are packed with their content.+ // Folders are packed with their content.if (File.Exists(file.SourcePath) || Directory.Exists(file.SourcePath))inputs.Add(file);elsediff --git a/src/Filee.Core/Presets/OutputPathResolver.cs b/src/Filee.Core/Presets/OutputPathResolver.csindex bdf3c108..7f3d52d4 100644--- a/src/Filee.Core/Presets/OutputPathResolver.cs+++ b/src/Filee.Core/Presets/OutputPathResolver.cs@@ -24,6 +24,8 @@ public static class OutputPathResolverpublic static string? Resolve(OutputRule rule, Tokens tokens, string targetExtension,Func<string, bool> exists, string? suffix = null){+ // A folder given as "Photos\" (the command line keeps what was typed) is named and placed like "Photos".+ tokens = tokens with { SourcePath = Path.TrimEndingDirectorySeparator(tokens.SourcePath) };var sourceDir = Path.GetDirectoryName(Path.GetFullPath(tokens.SourcePath)) ?? "";var dir = rule.Location switch{diff --git a/tests/Filee.App.Tests/OtherFileManagerTests.cs b/tests/Filee.App.Tests/OtherFileManagerTests.csindex 1d34c5f7..2b1348fa 100644--- a/tests/Filee.App.Tests/OtherFileManagerTests.cs+++ b/tests/Filee.App.Tests/OtherFileManagerTests.cs@@ -44,9 +44,9 @@ public class OtherFileManagerTestsFile.WriteAllBytes(file, [1]);try{- Assert.True(DraggedFiles.IsFileOrFolder(file));- Assert.True(DraggedFiles.IsFileOrFolder(folder));- Assert.False(DraggedFiles.IsFileOrFolder(Path.Combine(folder, "missing.png")));+ Assert.True(ConversionService.Exists(file));+ Assert.True(ConversionService.Exists(folder));+ Assert.False(ConversionService.Exists(Path.Combine(folder, "missing.png")));}finally{diff --git a/tests/Filee.App.Tests/RadialControllerTests.cs b/tests/Filee.App.Tests/RadialControllerTests.csindex ede64667..2c99a484 100644--- a/tests/Filee.App.Tests/RadialControllerTests.cs+++ b/tests/Filee.App.Tests/RadialControllerTests.cs@@ -5,6 +5,7 @@using Avalonia.Headless.XUnit;using Filee.App.Controls;using Filee.App.Services;+using Filee.Core.Presets;namespace Filee.App.Tests;@@ -57,4 +58,24 @@ public class RadialControllerTestsAssert.False(radial.IsVisible);Assert.False(radial.Window.IsVisible);}++ [Fact]+ public void Folders_only_go_into_one_archive()+ {+ var folder = Directory.CreateTempSubdirectory("filee-donut-folder-").FullName;+ try+ {+ var file = Path.Combine(folder, "1.png");+ var zip = new Preset { TargetFormat = "zip", Archive = { CombineIntoOne = true } };++ // Issue #186: a dragged folder goes into "Compress into one archive"; other presets take only the files.+ Assert.Equal([folder, file], RadialController.SourcesFor(zip, [folder, file]));+ Assert.Equal([file], RadialController.SourcesFor(new Preset { TargetFormat = "jpg" }, [folder, file]));+ Assert.Empty(RadialController.SourcesFor(new Preset { TargetFormat = "zip" }, [folder]));+ }+ finally+ {+ Directory.Delete(folder, recursive: true);+ }+ }}diff --git a/tests/Filee.Core.Tests/JobQueueTests.cs b/tests/Filee.Core.Tests/JobQueueTests.csindex 9b07989c..546258df 100644--- a/tests/Filee.Core.Tests/JobQueueTests.cs+++ b/tests/Filee.Core.Tests/JobQueueTests.cs@@ -352,6 +352,20 @@ public class JobQueueTestsAssert.Equal([empty, folder], combiner.Inputs);}+ [Fact]+ public async Task A_folder_ending_in_a_separator_is_packed_next_to_itself()+ {+ // The command line keeps "Photos\" as typed: the archive is still Photos_files.zip beside the folder.+ using var dir = new TempDir();+ var folder = Directory.CreateDirectory(Path.Combine(dir.Path, "Photos")).FullName;+ await using var queue = new JobQueue(new ConverterCatalog([]), combiner: new FakeCombiner());+ var preset = new Preset { TargetFormat = "zip", Archive = { CombineIntoOne = true }, Output = { FileNamePattern = "{name}_files" } };++ var job = await Run(queue, [folder + Path.DirectorySeparatorChar], preset);++ Assert.Equal(Path.Combine(dir.Path, "Photos_files.zip"), job.Outputs.Single());+ }+[Fact]public async Task No_route_is_reported(){diff --git a/tests/Filee.Core.Tests/OutputPathResolverTests.cs b/tests/Filee.Core.Tests/OutputPathResolverTests.csindex a4d98d4e..cf98df7d 100644--- a/tests/Filee.Core.Tests/OutputPathResolverTests.cs+++ b/tests/Filee.Core.Tests/OutputPathResolverTests.cs@@ -49,6 +49,17 @@ public class OutputPathResolverTestsAssert.Equal(Path.Combine(dir.Path, "photos (2)"), path);}+ [Fact]+ public void A_folder_ending_in_a_separator_is_named_and_placed_like_the_folder()+ {+ using var dir = new TempDir();+ var folder = Directory.CreateDirectory(Path.Combine(dir.Path, "Photos")).FullName;++ var path = OutputPathResolver.Resolve(new OutputRule(), Tokens(folder + Path.DirectorySeparatorChar), "zip", File.Exists);++ Assert.Equal(Path.Combine(dir.Path, "Photos.zip"), path);+ }+[Fact]public void Existing_file_gets_a_number_by_default(){