Advertisement
Flynny85

Maya archive to external location

Nov 26th, 2015
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.36 KB | None | 0 0
  1. import maya.cmds as cmds
  2. import maya.mel as mel
  3. import shutil
  4. import os
  5. import sys
  6.  
  7.  
  8. _ExtDrive_Path = "C:\Users\kflynn\Google Drive\Twenty2CansHappyAnims"
  9.  
  10. def Archive_Me_To_Gdrive():
  11.     ExternalPathExists = os.path.exists( _ExtDrive_Path )
  12.     if ExternalPathExists is True:
  13.         Current_File = cmds.file( sn=True , query=True)
  14.         FileName = FileNameStrip_gdrive( Current_File )
  15.         mel.eval( 'ArchiveScene;' )
  16.         Exists_test = cmds.file( ( Current_File + '.zip') , q=True, ex=True )
  17.         if Exists_test is True:
  18.             shutil.copyfile( ( Current_File + '.zip') , ( _ExtDrive_Path + "/" + FileName + '.zip' ) )
  19.             ZipExists_test = cmds.file( ( _ExtDrive_Path + "/" + FileName + '.zip' ) , q=True, ex=True )
  20.             if ZipExists_test is True:
  21.                 os.remove( ( Current_File + '.zip') )
  22.                 gui_message( 'Successfully copied file to gdrive location. - ' + ( FileName + '.zip' ) )
  23.             else:
  24.                 gui_message( "File copy to External path seems to of failed? Possible disconnection?" )                
  25.         else:
  26.             gui_message( ( "Zip archive file doesn't exist at file location - " + Current_File + " Aborting File copy") )      
  27.     else:
  28.         gui_message( "External Path doesn't exist." )
  29.        
  30. def FileNameStrip_gdrive( _FilePath ):
  31.     tmp = _FilePath.split('/') 
  32.     tmp2 = tmp[-1]
  33.     return tmp2
  34.  
  35.    
  36. def gui_message(message):
  37.     if message:
  38.         sys.stdout.write('# ' + ' - ' + message + ' #\n')
  39.    
  40. Archive_Me_To_Gdrive()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement