Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajouter une fonction pour renommer les métadonnées XML avec leur titre et identifiant en nom de fichier #2

Open
Guts opened this issue Nov 20, 2018 · 0 comments

Comments

@Guts
Copy link
Contributor

Guts commented Nov 20, 2018

Exemple de structure avec les exports de géosource :

export-full-1542728453496
    Fiche
         0aad7122-baa3-42b4-8d79-cf9c3e83035c
	      metadata	
                    metadata.xml
              private
	      public
              info.xml
    Catalogue d’attribut
        0a80da9e-c5dc-4343-97fa-b6d5e05dfa9e
	      metadata	
                    metadata.xml
              private
	      public
              info.xml

Vieux script à MAJ et inclure :

from os import path, rename, walk

path_src = path.realpath(r"C:\Users\XXXXXXXXX\Downloads\export-full-1503398299781")
path_dest = path.realpath(r"C:\Users\XXXXXXXX\Downloads\export-full-1503398299781")

for root, dirs, files in walk(path_src):
    for i in files:
        extension = path.splitext(path.join(root, i))[1]
        filename = path.basename(path.join(root, i))
        # print(i, filename, extension)
        if extension == ".xml" and "metadata" in i:
            #print(path.dirname(path.join(root, i)))
            md_id = path.split(path.dirname(path.dirname(path.join(root, i ))))[1]
            # print(i, filename, extension)
            rename(path.join(root,i), path.join(path_dest, md_id + extension))
            
leodarengosse added a commit that referenced this issue Nov 30, 2018
Le script copie les fichiers metadata.xml dans un répertoire de destination et les renomme avec l'identifiant et le titre de la métadonnée
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant