mv command

Peter pfk at
Mon Dec 31 09:52:37 EST 2001

I'm new to Python, and can't find the way to move a file individually
from a for loop to another directory.



import os, sys, commands, string

lscmd = 'ls '
lsdir = '/home/pk/old'
lsmask = '*.txt'
mvdir = 'home/pk/new'
cmdtxt = lscmd + lsdir + '/' + lsmask
print cmdtxt
f = commands.getstatusoutput(cmdtxt)
print f
print '[', f[0],']', f[1]

if f[0] == 0:
	f_split = string.split(f[1],'\n')
	print f_split

	for x in f_split:		 
		 print '-->', x
	print 'no file corresponding to lsmask'

More information about the Python-list mailing list