Subject: Re: os.chdir does not work, but does the os.rename work??? - msg#00114
List: lang.jython.user
Thanks for the answer but this also does not work:
from java import io
src = "D:\test.txt"
dest = "D:\test2.txt"
oldfile = io.File(src)
newfile = io.File(dest)
oldfile.renameTo(dest)
Did I do something wrong???
Mathias
Jeff Emanuel schrieb:
A workaround is to use java.io.File.renameTo.
Mathias Tirtasana wrote:
Hi folks,
I am trying to rename a file with jython but it returns :
OSError: [Errno 0] couldn't rename file:
I read in the FAQ that some functionaltiy of the os module is not
implemented, but is the rename function?
Or is there an onboard workaround?
Greetings
Mathias
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Jython-users mailing list
Jython-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jython-users
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Jython-users mailing list
Jython-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jython-users
--
Dipl. Inf. (FH) Mathias Tirtasana
Westfaelische Wilhelms-Universitaet Muenster
Zentrum fuer Informationsverabeitung (ZIV)
Röntgenstraße 9 -13
D-48149 Muenster
E-Mail: mathias.tirtasana@xxxxxxxxxxxxxxx
Telefon: +49 251 83 -31626
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_idv28&alloc_id845&op=click
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
(no subject)
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_idv28&alloc_id845&op=click
Next Message by Date:
click to view message preview
Re: os.chdir does not work, but does the os.rename work???
Mathias Tirtasana wrote:
Hi folks,
I am trying to rename a file with jython but it returns :
OSError: [Errno 0] couldn't rename file:
I read in the FAQ that some functionaltiy of the os module is not
implemented, but is the rename function?
Or is there an onboard workaround?
os.rename() works for me in Jython 2.1:
os.listdir('.')
['10827_it_enus', 'bar.txt']
os.rename('bar.txt', 'foo.txt')
os.listdir('.')
['10827_it_enus', 'foo.txt']
Are you sure there isn't another reason the rename is failing, such as a
read-only file or another file with the name you are trying to change to? Can
you rename the file in the shell or Windows Explorer?
Kent
--
http://www.kentsjohnson.com
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
Previous Message by Thread:
click to view message preview
Re: os.chdir does not work, but does the os.rename work???
A workaround is to use java.io.File.renameTo.
Mathias Tirtasana wrote:
Hi folks,
I am trying to rename a file with jython but it returns :
OSError: [Errno 0] couldn't rename file:
I read in the FAQ that some functionaltiy of the os module is not
implemented, but is the rename function?
Or is there an onboard workaround?
Greetings
Mathias
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Jython-users mailing list
Jython-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jython-users
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
Next Message by Thread:
click to view message preview
Re: os.chdir does not work, but does the os.rename work???
Yes, you did.
The argument to renameTo is newfile, not dest.
You should also use / instead of \.
Regards,
Nico
On 11/23/05, Mathias Tirtasana <mathias.tirtasana@xxxxxxxxxxxxxxx> wrote:
Thanks for the answer but this also does not work:from java import iosrc = "D:\test.txt"
dest = "D:\test2.txt"oldfile = io.File(src)newfile = io.File(dest)oldfile.renameTo(dest)Did I do something wrong???MathiasJeff Emanuel schrieb:> A workaround is to use
java.io.File.renameTo.>> Mathias Tirtasana wrote:>> Hi folks,>> I am trying to rename a file with jython but it returns :>> OSError: [Errno 0] couldn't rename file:>> I read in the FAQ that some functionaltiy of the os module is not
>> implemented, but is the rename function?>> Or is there an onboard workaround?>>>> Greetings>> Mathias>>>>>> -------------------------------------------------------
>> This SF.Net email is sponsored by the JBoss Inc. Get Certified Today>> Register for a JBoss Training Course. Free Certification Exam>> for All Training Attendees Through End of 2005. For more info visit:
>> http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click>> _______________________________________________>> Jython-users mailing list
>> Jython-users@xxxxxxxxxxxxxxxxxxxxx>> https://lists.sourceforge.net/lists/listinfo/jython-users
>>> -------------------------------------------------------> This SF.Net email is sponsored by the JBoss Inc. Get Certified Today> Register for a JBoss Training Course. Free Certification Exam
> for All Training Attendees Through End of 2005. For more info visit:> http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
> _______________________________________________> Jython-users mailing list> Jython-users@xxxxxxxxxxxxxxxxxxxxx>
https://lists.sourceforge.net/lists/listinfo/jython-users--Dipl. Inf. (FH) Mathias TirtasanaWestfaelische Wilhelms-Universitaet MuensterZentrum fuer Informationsverabeitung (ZIV)Röntgenstraße 9 -13
D-48149 MuensterE-Mail: mathias.tirtasana@xxxxxxxxxxxxxxxTelefon: +49 251 83 -31626-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified TodayRegister for a JBoss Training Course. Free Certification Examfor All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_idv28&alloc_id845&opclick_______________________________________________Jython-users mailing listJython-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jython-users