shutils.move lose files !

Sibylle Koczian Sibylle.Koczian at Bibliothek.Uni-Augsburg.de
Mon Mar 22 15:27:38 CET 2004


Miki Tebeka schrieb:

> Hello Shagshag,
> 
>>>>> import os
>>>>> os.mkdir('c:/stupid')
>>>>> open('c:/stupid/atest.txt', 'w').write('a file')
>>>>> os.listdir('c:/stupid')
>>
>>
>> ['atest.txt']
>>
>>>>> import shutil
>>>>> shutil.move('c:/stupid', 'c:/stupid/donotexist')
>>>>> os.listdir('c:/stupid')
>>
>>
>>
>> Traceback (most recent call last):
>>   File "<pyshell#22>", line 1, in -toplevel-
>>     os.listdir('c:/stupid')
>> WindowsError: [Errno 3] Le chemin d'accès spécifié est introuvable:
>> 'c:/stupid/*.*'
> 
>  >>> from os import mkdir, listdir
>  >>> from shutil import move
>  >>> mkdir("c:/temp/xxx")
>  >>> open("c:/temp/xxx/moo", "w").write("moo")
>  >>> move("c:/temp/xxx/moo", "c:/temp/xxx/goo")
>  >>> listdir("c:/temp/xxx")
> ['goo']
>  >>>
> 
> This is on win2k
> Miki

But it's not the same thing: you are renaming a file, leaving it in its 
original directory. The original poster tried to move the directory into 
a subdirectory of itself.

-- 
Dr. Sibylle Koczian
Universitaetsbibliothek, Abt. Naturwiss.
D-86135 Augsburg

Tel.: (0821) 598-2400, Fax : (0821) 598-2410
e-mail : Sibylle.Koczian at Bibliothek.Uni-Augsburg.DE




More information about the Python-list mailing list