pymel.core.system.sysFile

static system.sysFile(*args, **kwargs)

This command provides a system independent way to create a directory or to rename or delete a file.

Flags:
Long name (short name) Argument Types Properties
copy (cp) unicode ../../../_images/create.gif
 
Copy the file to the name given by the newFileName paramter.
delete (delete) bool ../../../_images/create.gif
 
Deletes the file.
makeDir (md) bool ../../../_images/create.gif
 
Create the directory path given in the parameter. This will create the entire path if more than one directory needs to be created.
move (mov) unicode ../../../_images/create.gif
 
Behaves identically to the -rename flag and remains for compatibility with old scripts
removeEmptyDir (red) bool ../../../_images/create.gif
 

Delete the directory path given in the parameter if the directory is empty. The command will not delete a directory which is not empty. Flag can have multiple arguments, passed either as a tuple or a list.

rename (ren) unicode ../../../_images/create.gif
 
Rename the file to the name given by the newFileName parameter.

Derived from mel command maya.cmds.sysFile

Example:

import pymel.core as pm

# Create a new directory path
pm.sysFile( 'C:/temp/mayaStuff', makeDir=True )# Windows
# Result: False #
pm.sysFile( '/tmp/mayaStuff', makeDir=True )# Unix
# Result: True #

# Move a scene to the new directory (we can rename it at the same time).
pm.sysFile( 'C:/maya/projects/default/scenes/myScene.mb', rename='C:/temp/mayaStuff/myScene.mb.trash' )# Windows
# Result: False #
pm.sysFile( '/maya/projects/default/scenes/myScene.mb', rename='/tmp/mayaStuff/myScene.mb.trash' )# Unix
# Result: False #


# Rename the scene to "myScene.will.be.deleted"
pm.sysFile( 'C:/temp/mayaStuff/myScene.mb.trash', rename='C:/temp/mayaStuff/myScene.will.be.deleted' )# Windows
# Result: False #
pm.sysFile( '/tmp/mayaStuff/myScene.mb.trash', rename='/tmp/mayaStuff/myScene.will.be.deleted' )# Unix
# Result: False #

# Copy a scene to the new directory
destWindows = "C:/temp/mayaStuff/myScene.mb.trash"
srcWindows = "C:/maya/projects/default/scenes/myScene.mb"
pm.sysFile( srcWindows, copy=destWindows )# Windows
# Result: False #

destUnix = "/tmp/mayaStuff/myScene.mb.trash"
srcUnix = "maya/projects/default/scenes/myScene.mb"
pm.sysFile( srcUnix, copy=destUnix )# Unix
# Result: False #

# Delete the scene
pm.sysFile( 'C:/temp/mayaStuff/myScene.will.be.deleted', delete=True )# Windows
# Result: False #
pm.sysFile( '/tmp/mayaStuff/myScene.will.be.deleted', delete=True )# Unix
# Result: False #

Previous topic

pymel.core.system.showHelp

Next topic

pymel.core.system.timer

Core

Core Modules

Other Modules

This Page