Files
paperless-ngx/src/documents/management/commands/document_renamer.py
T
stumpylog 0770b4fcc2 Fix: rename and retag documents one file move at a time
document_renamer sent a fake post_save per document to trigger the move, and document_retagger moved a document once for each field it assigned.

The renamer calls move_files_for_document directly for each document, so progress reflects real work. The retagger opens a file move scope per document, so each document is moved once after all of its assignments.
2026-11-03 15:09:30 -08:00

18 lines
516 B
Python

from documents.file_moves import move_files_for_document
from documents.management.commands.base import PaperlessCommand
from documents.models import Document
class Command(PaperlessCommand):
help = "Rename all documents"
supports_progress_bar = True
supports_multiprocessing = False
def handle(self, *args, **options):
for document in self.track(
Document.objects.only("pk"),
description="Renaming...",
):
move_files_for_document(document.pk)