decryptage_copies_AMC.py
| 1 | #!/usr/bin/env python3
|
|---|---|
| 2 | # -*- coding: utf-8 -*-
|
| 3 | |
| 4 | import sys |
| 5 | # subprocess : seulement depuis la version 3.x de Python
|
| 6 | import subprocess |
| 7 | import os |
| 8 | |
| 9 | if sys.argv[1] == "?" : |
| 10 | print("[DossierCrypter] [DossierDecrypter] [OwnerPwd] [Suffixe]")
|
| 11 | print("Puis CTRL+R pour rafraîchir l'affichage de l'explorateur.")
|
| 12 | sys.exit() |
| 13 | |
| 14 | |
| 15 | NomDossierCrypter = sys.argv[1]
|
| 16 | NomDossierDecrypter = sys.argv[2]
|
| 17 | OwnerPwd = sys.argv[3] # OwnerPass |
| 18 | Suffixe = sys.argv[4]
|
| 19 | |
| 20 | # NP = eval(sys.argv[3])
|
| 21 | # NTotal = eval(sys.argv[4])
|
| 22 | |
| 23 | k = 0
|
| 24 | |
| 25 | thepath = os.getcwd() |
| 26 | repini = thepath+"/"+NomDossierCrypter # dossier avec les fichiers initiaux (non cryptés) |
| 27 | repdest = thepath+"/"+NomDossierDecrypter # dossier qui contiendrontles fichiers cryptés |
| 28 | |
| 29 | |
| 30 | |
| 31 | noms = os.listdir(repini) |
| 32 | for nom in noms: |
| 33 | Temp = nom.split(".") # Récupère tout ce qui est avant le ".pdf" |
| 34 | NameFile = Temp[0]
|
| 35 | File = os.path.join(repini, nom) # permet de "coller" le nom du répertoire et le nom du fichier avec un "/" entre les deux.
|
| 36 | #print(nfc)
|
| 37 | #k = k + 1 # Numéro de la ligne dans le fichier csv (commence à 0)
|
| 38 | #NomFichier = "QCM_Number-"+GetElement(fname,k,2)+"-"+GetElement(fname,k,0)+"-"+GetElement(fname,k,1)+"_"+suffixe+".pdf"
|
| 39 | #nfcfinal = os.path.join(repfinal, NomFichier)
|
| 40 | NomFichierDecrypter = repdest+"/"+NameFile+"_"+Suffixe+".pdf" |
| 41 | subprocess.call(["qpdf","--password="+OwnerPwd, "--decrypt",File,NomFichierDecrypter]) |
| 42 | |
| 43 |