[Tutor] shutil question? on copying files

ibraheem umaru-mohammed ium@micromuse.com
Thu, 5 Apr 2001 19:39:14 +0100


[Scott Ralph Comboni wrote...]
-| I have a question in regards to the shutil module.  I'm trying to copy
-| via a wildcard shutil.copy('/project/tambora/packages/*tar*', '/tmp')
-| and I get this.
-| 
-|  File "<stdin>", line 1, in ?
-|   File "/usr/local/lib/python2.0/shutil.py", line 26, in copyfile
-|     fsrc = open(src, 'rb')
-| IOError: [Errno 2] No such file or directory:
-| '/projects/tambora/packages/*tar*'
-| 
-| It works fine if I put the complete path name in but I'd like to be able
-| to wildcard this. IS there a way to do this or another module to use? I
-| need to preform this function on *NIX and NT.

I don't know how you would do it under NT but you can try using the glob module under *nixes:

	>>>import glob
	>>> glob.glob("/boot/*")
	['/boot/System.map', '/boot/System.map-2.4.0-test9',
	'/boot/boot.0300', '/boot/boot.0303', '/boot/boot.b',
	'/boot/chain.b', '/boot/kernel.h', '/boot/lost+found',
	'/boot/map', '/boot/module-info', '/boot/os2_d.b',
	'/boot/System.map.old', '/boot/boot.0305', '/boot/boot.0200',
	'/boot/System.map-2.2.18', '/boot/vmlinuz.old',
	'/boot/vmlinuz-2.4.0-test9', '/boot/vmlinuz-2.2.18',
	'/boot/vmlinuz-2.2.18.prev', '/boot/boot.0306',
	'/boot/boot.lnx']
	>>>  
	
HTH,

Kindest regards,

	--ibs.

-- 
Live never to be ashamed if anything you do or say is
published around the world -- even if what is published is not true.
		-- Messiah's Handbook : Reminders for the Advanced Soul