mv command

Pieter Claerhout pieter.claerhout at pandora.be
Mon Dec 31 10:05:17 EST 2001


Hi Peter,

you can use the os.rename function for this.

Pieter

-----Original Message-----
From: python-list-admin at python.org
[mailto:python-list-admin at python.org]On Behalf Of Peter
Sent: Monday, December 31, 2001 3:53 PM
To: python-list at python.org
Subject: mv command


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'
-- 
http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list