You might need to make folders and link files from time to time. The os module is used for both of these tasks.
import os os.mkdir('newdir') # like mkdir os.makedirs('notexistent/bogus/newdir') # like mkdir -p
os.mkdir and os.makedirs offer little in the way of surprises. os.mkdir works like mkdir and os.makedirs works like mkdir -p, creating any intermediate directories it needs to create the specified directory.
import os os.link('file', 'newhardlink') # think ln os.symlink('fileordir', 'newsymlink') # think ln -s
os.link creates hard links to files just like ln. os.symlink creates soft links in the way that ln -s does. I love how python works in such a predictable fashion.
Posted by
on January 11, 2009
at 5:48
Tagged as:
python
shell_scripting
