Advertisement
Guest User

test.py

a guest
Apr 1st, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. import sys
  2. from os import *
  3.  
  4. userpath = sys.argv[1]
  5.  
  6. def validates_path(fpath): #valida o caminho até o diretório
  7.     if (path.exists(fpath) == False) or (path.isdir(fpath) == False):
  8.         fpath = str(input("Error! Insert a valid path: "))
  9.         validates_path(fpath)
  10.     return True
  11.  
  12. validates_path(userpath)
  13. command0 ='cd ' + userpath
  14. system(command0)
  15. archives = listdir(userpath)
  16.  
  17. confirmation = input("You entered the path:\n" + userpath + ".\nAre you sure you want to proceed (y/N)?: ")
  18.  
  19. if confirmation in ['y', 'Y']:
  20.     for archive in archives:
  21.         archive_path = userpath + '/' + archive
  22.         new_archive_path = userpath + '/file_' + archive
  23.         system('mv ' + archive_path + ' ' + new_archive_path)
  24. else:
  25.     print("End process.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement