mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-31 02:27:10 -04:00 
			
		
		
		
	Added tool to rename all documents according to the lastest filename
format
This commit is contained in:
		
							parent
							
								
									6813805712
								
							
						
					
					
						commit
						a79a0ca302
					
				
							
								
								
									
										24
									
								
								src/documents/management/commands/document_renamer.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/documents/management/commands/document_renamer.py
									
									
									
									
									
										Normal file
									
								
							| @ -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() | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user