import os
L = os.listdir('.')
for x in L:
print '!'+x+'!'+x[0]
if x != 'rename.py':
y = 'Kapustin (Hamelin): '+x
os.rename(x,y)
I get
Traceback (most recent call last):
File "<stdin>", line 9, in ?
OSError: [Errno 22] Invalid argument
TIA,
jb 5 8340
jblazi wrote: os.rename(x,y)
Traceback (most recent call last): File "<stdin>", line 9, in ? OSError: [Errno 22] Invalid argument
Works fine here (Linux). Maybe you're using a platform where you use
invalid characters for the filename?
--
Ciao,
Matteo
jblazi wrote: import os
L = os.listdir('.')
for x in L: print '!'+x+'!'+x[0] if x != 'rename.py': y = 'Kapustin (Hamelin): '+x os.rename(x,y)
I get
Traceback (most recent call last): File "<stdin>", line 9, in ? OSError: [Errno 22] Invalid argument
You didn't specify your OS, version of Python, etc,
but perhaps we can guess why it doesn't work anyway.
Have you tried executing the equivalent command manually,
either from the command line or from, say, Explorer (assuming
you're on Windows)? Can you rename any file to contain
parentheses and colons on your OS? If not, there's
your answer.
-Peter
Just a guess here, but is ':' a valid filename character on your OS?
Most OSes seem to have it reserved for system use. Try using a
hyphen.
Chris
On Mon, 16 Aug 2004 15:03:51 +0200, jblazi <jb****@hotmail.com> wrote: import os
L = os.listdir('.')
for x in L: print '!'+x+'!'+x[0] if x != 'rename.py': y = 'Kapustin (Hamelin): '+x os.rename(x,y)
I get
Traceback (most recent call last): File "<stdin>", line 9, in ? OSError: [Errno 22] Invalid argument
TIA,
jb
-- http://mail.python.org/mailman/listinfo/python-list
--
Still searching for an even prime > 2!
"jblazi" <jb****@hotmail.com> wrote in message news:pa****************************@hotmail.com... y = 'Kapustin (Hamelin): '+x os.rename(x,y) OSError: [Errno 22] Invalid argument
You didn't say what platform you are on but if it's Windows, then
colons aren't allowed in filenames.
On Mon, 16 Aug 2004 14:16:21 +0100, Richard Brodie wrote: You didn't say what platform you are on but if it's Windows, then colons aren't allowed in filenames.
Yes. Now it seems, my age begins to tell, I did not used to be so dumb...
Thx.
jb This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Xiangliang Meng |
last post by:
Hi, all.
How does this 'sizeof(*area)' work? I think the reason is the sentence in
C99: If the operand has type ¡®¡®pointer to type¡¯¡¯, the result has type
¡®¡®type¡¯¡¯, but I'm not sure. Could...
|
by: Dave |
last post by:
I build a very simple program that I put at the end of this post. This
program is just supposed to put a button on the screen and exit the program
when I press the escape button. But pressing the...
|
by: lovecreatesbeauty |
last post by:
`Writing C code is very simple', one guy related to my work said.
I'm not sure whether he is an expert or not. What he said about C
programming like this can't convince me. I think there should be...
|
by: Anoop |
last post by:
Hi,
I am new to this newsgroup and need help in the following questions.
1. I am workin' on a GUI application. Does C# provides Layout Managers the
way Java does to design GUI? I know that it...
|
by: christophe.chazeau |
last post by:
Hi,
I have a problem with a really simple chunk of code which should work
but does obviously does not.
This chunk of code is just a POC aimed at finding a bug in a larger
project in which the...
|
by: Zytan |
last post by:
I see that static is more restricted in C# than in C++. It appears
usable only on classes and methods, and data members, but cannot be
created within a method itself. Surely this is possible in...
|
by: Soren S. Jorgensen |
last post by:
Hi,
I'm trying to read some messages (native structs) from a kernel mode
mini-filter driver. I'm using my own implementation of IAsyncResult to
pack/unpack the NativeOverlapped structure, and...
|
by: 7stud |
last post by:
I have the following two identical clients
#test1.py:-----------
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = 'localhost'
port = 5052 #server port
|
by: jlhsgcib |
last post by:
Hello,
I have the following snippet of code:
sub getPasswordStatus {
my ($login, $password) = @_;
my$quotedLogin = quotemeta($login);
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |