A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
add prefix option to administration exporter
Matthieu Helleboid896304ccaa72
diff --git a/docs/administration.md b/docs/administration.mdindex e7fa74fec..7cbcf95b9 100644--- a/docs/administration.md+++ b/docs/administration.md@@ -227,11 +227,12 @@ is not a TTY" errors. For example:`docker-compose exec -T webserver document_exporter ../export````-document_exporter target [-c] [-f] [-d] [-na] [-nt]+document_exporter target [-c] [-f] [-p] [-d] [-na] [-nt]optional arguments:-c, --compare-checksums-f, --use-filename-format+-p, --use-filename-prefix-d, --delete-na, --no-archive-nt, --no-thumbnail@@ -277,6 +278,10 @@ The filenames generated by this command follow the formatpaperless to use `PAPERLESS_FILENAME_FORMAT` for exported filenamesinstead, specify `--use-filename-format`.+If `-p` or `--use-filename-format` is provided, Files will be exported+in dedicated folders according to their nature: `archive`, `originals`+or `thumbnails`+!!! warningIf exporting with the file name format, there may be errors due todiff --git a/src/documents/management/commands/document_exporter.py b/src/documents/management/commands/document_exporter.pyindex b44317969..b6070b93d 100644--- a/src/documents/management/commands/document_exporter.py+++ b/src/documents/management/commands/document_exporter.py@@ -72,6 +72,15 @@ class Command(BaseCommand):"export directory, if configured.",)+ parser.add_argument(+ "-p",+ "--use-filename-prefix",+ default=False,+ action="store_true",+ help="Export files in dedicated folders according to their nature: "+ "archive, originals or thumbnails",+ )+parser.add_argument("-d","--delete",@@ -97,6 +106,7 @@ class Command(BaseCommand):action="store_true",help="Avoid exporting thumbnail files",)+parser.add_argument("--no-progress-bar",default=False,@@ -119,6 +129,7 @@ class Command(BaseCommand):self.exported_files: List[Path] = []self.compare_checksums = Falseself.use_filename_format = False+ self.use_filename_prefix = Falseself.delete = Falseself.no_archive = Falseself.no_thumbnail = False@@ -128,6 +139,7 @@ class Command(BaseCommand):self.target = Path(options["target"]).resolve()self.compare_checksums = options["compare_checksums"]self.use_filename_format = options["use_filename_format"]+ self.use_filename_prefix = options["use_filename_prefix"]self.delete = options["delete"]self.no_archive = options["no_archive"]self.no_thumbnail = options["no_thumbnail"]@@ -262,11 +274,15 @@ class Command(BaseCommand):# 3.3. write filenames into manifestoriginal_name = base_name+ if self.use_filename_prefix:+ original_name = ("originals" / Path(original_name)).resolve()original_target = (self.target / Path(original_name)).resolve()document_dict[EXPORTER_FILE_NAME] = original_nameif not self.no_thumbnail:thumbnail_name = base_name + "-thumbnail.webp"+ if self.use_filename_prefix:+ thumbnail_name = ("thumbnails" / Path(thumbnail_name)).resolve()thumbnail_target = (self.target / Path(thumbnail_name)).resolve()document_dict[EXPORTER_THUMBNAIL_NAME] = thumbnail_nameelse:@@ -274,6 +290,8 @@ class Command(BaseCommand):if not self.no_archive and document.has_archive_version:archive_name = base_name + "-archive.pdf"+ if self.use_filename_prefix:+ archive_name = ("archive" / Path(archive_name)).resolve()archive_target = (self.target / Path(archive_name)).resolve()document_dict[EXPORTER_ARCHIVE_NAME] = archive_nameelse: