Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Added tool to rename all documents according to the lastest filename format

Wolf-Bastian Poettnera79a0ca302ed
diff --git a/src/documents/management/commands/document_renamer.py b/src/documents/management/commands/document_renamer.py
new file mode 100644
index 000000000..d7d77a111
--- /dev/null
+++ b/src/documents/management/commands/document_renamer.py
@@ -0,0 +1,24 @@
+from django.core.management.base import BaseCommand
+
+from documents.models import Document, Tag
+
+from ...mixins import Renderable
+
+
+class Command(Renderable, BaseCommand):
+
+ help = """
+ This will rename all documents to match the latest filename format.
+ """.replace(" ", "")
+
+ def __init__(self, *args, **kwargs):
+ self.verbosity = 0
+ BaseCommand.__init__(self, *args, **kwargs)
+
+ def handle(self, *args, **options):
+
+ self.verbosity = options["verbosity"]
+
+ for document in Document.objects.all():
+ # Saving the document again will generate a new filename and rename
+ document.save()