mv command

Peter pfk at advalvas.be
Mon Dec 31 15:52:37 CET 2001


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

Regards

Peter




#!/usr/bin/python
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
		
else:
	print 'no file corresponding to lsmask'



More information about the Python-list mailing list