mirror of
https://git.aramjonghu.nl/AramJonghu/file-organizer.git
synced 2026-06-07 01:48:24 +02:00
now detects documents
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
const std = @import("std");
|
||||
const classify = @import("classify.zig");
|
||||
|
||||
pub fn organize(io: std.Io, dir: std.Io.Dir, name: []const u8) !void {
|
||||
const category = classify.classify(name);
|
||||
try ensureCategoryDir(io, dir, category);
|
||||
}
|
||||
|
||||
fn ensureCategoryDir(io: std.Io, dir: std.Io.Dir, category: classify.Category) !void {
|
||||
const dest = switch (category) {
|
||||
.image => "Pictures",
|
||||
.document => "Documents",
|
||||
.music => "Music",
|
||||
.video => "Videos",
|
||||
.code => "Code",
|
||||
.other => return,
|
||||
};
|
||||
|
||||
try dir.createDirPath(io, dest);
|
||||
}
|
||||
Reference in New Issue
Block a user