miamondo

thumbnail.py

Apr 2nd, 2021 (edited)
119
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python3
  2. # -*- coding: utf8 -*-
  3.  
  4. # Copyright © 2020 Benoit Boudaud <https://miamondo.org/contact>
  5. # This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
  6. # License as published by the Free Software Foundation, either version 3 of the License, or any later version.
  7. # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
  8. # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. # You should have received a copy of the GNU General Public License along with this program.
  10. # If not, see <http://www.gnu.org/licenses/>
  11.  
  12. # PREREQUISITES
  13. # This script takes one argument which is the path to the directory whose icons you want to replace with thumbnails.
  14. # Ce script prend un argument qui est le chemin du répertoire dont vous voulez remplacer les icônes par des vignettes.
  15.  
  16. # Give permission to execute thumbnail.py and thumbnail.sh
  17.  
  18. import os
  19. import subprocess
  20. import sys
  21.  
  22. folder = sys.argv[1]  # Répertoire passé en argument
  23. cwd = os.path.abspath(os.path.dirname(sys.argv[0]))  # Current working directory
  24.  
  25. for root, dirs, files in os.walk(folder):
  26.     for file_ in files:
  27.         if not os.path.isdir(os.path.join(root, file_)):                    
  28.             subprocess.Popen([os.path.join(cwd, "thumbnail.sh"), root, file_])
  29.             break
  30.  
RAW Paste Data