Advertisement
tanmay606

simple python script of windows / linux file manager

Nov 27th, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.75 KB | None | 0 0
  1. #usr/bin/share/python
  2. #script codded by tanmay for all facebook and HF friends :)
  3. import shutil #function for system commands like copy,move etc
  4. import sys #for exit code and sys func
  5. from os import * #access to all os func
  6. def move_folder():
  7.  folder_to_move=raw_input("Folder to Move :$: ")
  8.  dest=raw_input("Location Where Move :$: ")
  9.  print '\n'
  10.  try:
  11.   shutil.move(folder_to_move,dest)
  12.   print '%s Moved Successfully To %s' %(folder_to_move,dest)
  13.   print '\n'
  14.   start()
  15.  except:
  16.   print 'Possible Errors will be : \n'
  17.   print 'System Cannot find path specified'
  18.   print 'Folder not exist'
  19.   raw_input('Press Enter To Restart')
  20.   start()
  21. def move_file():
  22.  file_to_move = raw_input('File to move :$: ')
  23.  dest_file=raw_input('Location where move :$: ')
  24.  print '\n'
  25.  try:
  26.   shutil.move(file_to_move,dest_file)
  27.   print '%s Moved Successfully To %s'%(file_to_move,dest_file)
  28.   print '\n'
  29.   start()
  30.  except:
  31.   print 'Possible Errors Will be : \n'
  32.   print 'System Cannot find the path specified'
  33.   print 'File not exist'
  34.   raw_input('Press Enter To Restart')
  35.   start()
  36. def del_fold():
  37.  fold_to_del = raw_input('Folder to delete :$: ')
  38.  try:
  39.   rmdir(fold_to_del)
  40.   start()
  41.  except WindowsError as msg:
  42.   print 'Error : %s' %msg[1]
  43.   raw_input('Press Enter To Restart')
  44.   start()
  45. def del_file():
  46.  file_to_del = raw_input('File to delete :$: ')
  47.  try:
  48.   remove(file_to_del)
  49.   start()
  50.  except OSError as msg:
  51.   print 'Error : %s'%msg[1]
  52.   print '\n'
  53.   raw_input('Press Enter To Restart')
  54.   start()
  55. def create_folder():
  56.  new_folder_name = raw_input("Enter new folder name :$: ")
  57.  try:
  58.   mkdir(new_folder_name)
  59.   start()
  60.  except:
  61.   print 'Access is Denied'
  62.   print '\n'
  63.   raw_input('Press Enter To Restart')
  64.   start()
  65. def dir_cont():
  66.  print '[+] items in [ %s ]' %getcwd()
  67.  for object in listdir(getcwd()):
  68.   print object
  69.  raw_input('Press Enter To Restart')
  70.  start()
  71. def error():
  72.  print ' ERROR : Invalid Choice or Empty Choice'
  73.  print '\n'
  74.  raw_input('Press Enter To Restart')
  75.  start()
  76. def rename_file():
  77.  file_to_rename=raw_input('File to rename :$: ')
  78.  newname = raw_input('New Name of File %s :$: '%file_to_rename)
  79.  try:
  80.   rename(file_to_rename,newname)
  81.   start()
  82.  except OSError as msg:
  83.   print 'Error :%s' %msg[1]
  84.   print '\n'
  85.   raw_input('Press Enter To Restart')
  86.   start()
  87. def change_dir():
  88.  loc_change_dir = raw_input('Path to change dir :$: ')
  89.  try:
  90.   chdir(loc_change_dir)
  91.   start()
  92.  except OSError as msg:
  93.   print 'Error : %s' %msg[1]
  94.   print '\n'
  95.   raw_input('Press Enter To Restart')
  96.   start()
  97. def shell_cmd():
  98.  cmd = raw_input('[+] root@13lackDeMon :$: ')
  99.  try:
  100.   st = system(cmd)
  101.   print st
  102.   print shell_cmd()
  103.  except KeyboardInterrupt:
  104.   print 'User Bye'
  105. def start():
  106.  try:
  107.   clear = system('clear')
  108.  except OSErrror:
  109.   clear = system('cls')
  110.  clear
  111.  print '[*] simple command line file manager codded by 13lackDeMon / Tanmay'
  112.  print '---------------------------------------------------------------------'
  113.  print '[##] Current Dir :$ %s' %getcwd()
  114.  print '**********************************'
  115.  print '\n'
  116.  print '[1] Move Folder \t[5] Rename File   \t[9] Create Folder\n[2] Move File\t\t[6] Change Dir  \t[10] Exit\n[3] Delete File \t[7] List Directory \n[4] Delete Folder \t[8] Excute Shell Command \n '
  117.  choice = raw_input('->')
  118.  if(choice=="1"):
  119.   move_folder()
  120.  elif(choice=="2"):
  121.   move_file()
  122.  elif(choice=="3"):
  123.   del_file()
  124.  elif(choice=="4"):
  125.   del_fold()
  126.  elif(choice=="5"):
  127.   rename_file()
  128.  elif(choice=="6"):
  129.   change_dir()
  130.  elif(choice=="7"):
  131.   dir_cont()
  132.  elif(choice=="8"):
  133.   shell_cmd()
  134.  elif(choice=="9"):
  135.   create_folder()
  136.  elif(choice=="10"):
  137.   print '\n\r' + "[!] Thanks for using 13lackDemon command line manger"
  138.   sys.exit(1)
  139.  else:
  140.   error()
  141.  
  142. start() #start script ! :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement