Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""LICENSE
2Copyright 2015 Hermann Krumrey <hermann@krumreyh.com>
4This file is part of toktokkie.
6toktokkie is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
11toktokkie is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
16You should have received a copy of the GNU General Public License
17along with toktokkie. If not, see <http://www.gnu.org/licenses/>.
18LICENSE"""
20import argparse
21from toktokkie.commands.Command import Command
22from toktokkie.Directory import Directory
25class RenameCommand(Command):
26 """
27 Class that encapsulates behaviour of the rename command
28 """
30 @classmethod
31 def name(cls) -> str:
32 """
33 :return: The command name
34 """
35 return "rename"
37 @classmethod
38 def help(cls) -> str:
39 """
40 :return: The help message for the command
41 """
42 return "Renames directory content based on IDs"
44 @classmethod
45 def prepare_parser(cls, parser: argparse.ArgumentParser):
46 """
47 Prepares an argumentparser for this command
48 :param parser: The parser to prepare
49 :return: None
50 """
51 cls.add_directories_arg(parser)
52 parser.add_argument("--noconfirm", action="store_true",
53 help="Skips the user confirmation step")
54 parser.add_argument("--include-title", action="store_true",
55 help="Also renames the title based on ID info")
57 def execute(self):
58 """
59 Executes the command
60 :return: None
61 """
62 for directory in Directory.load_directories(self.args.directories):
63 directory.metadata.rename(
64 noconfirm=self.args.noconfirm,
65 skip_title=not self.args.include_title
66 )