From 3d9f8d46ee2a01f8f0b57bdc15a604b4f1e7051a Mon Sep 17 00:00:00 2001 From: Jakob Moser Date: Sun, 1 Jun 2025 10:58:40 +0200 Subject: [PATCH] Implement move instruction --- karaokatalog/instructions/MoveInstruction.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/karaokatalog/instructions/MoveInstruction.py b/karaokatalog/instructions/MoveInstruction.py index cf2a157..e1cc136 100644 --- a/karaokatalog/instructions/MoveInstruction.py +++ b/karaokatalog/instructions/MoveInstruction.py @@ -1,3 +1,4 @@ +import shutil from dataclasses import dataclass from pathlib import Path @@ -15,4 +16,7 @@ class MoveInstruction(Instruction): new_path: Path def __call__(self) -> None: - raise NotImplementedError() # TODO + if self.new_path.exists(): + raise FileExistsError("New path already exists, not moving anything") + + shutil.move(self.old_path, self.new_path)