paperless-ngx/src/documents/management/commands/document_renamer.py

33 lines
838 B
Python
Raw Normal View History

import logging
import tqdm
from django.core.management.base import BaseCommand
2020-12-12 20:32:11 +01:00
from django.db.models.signals import post_save
2020-11-12 21:09:45 +01:00
from documents.models import Document
2021-02-04 23:40:53 +01:00
class Command(BaseCommand):
help = """
This will rename all documents to match the latest filename format.
""".replace(" ", "")
def add_arguments(self, parser):
parser.add_argument(
"--no-progress-bar",
default=False,
action="store_true",
help="If set, the progress bar will not be shown"
)
def handle(self, *args, **options):
logging.getLogger().handlers[0].level = logging.ERROR
for document in tqdm.tqdm(
Document.objects.all(),
disable=options['no_progress_bar']
):
2020-12-12 20:32:11 +01:00
post_save.send(Document, instance=document)