import os, time
os.system("dir /p /l /o:n /w > directory.txt")
gg = open("directory.txt")
g = gg.readlines()
gg.close()
os.system("del directory.txt")
g = g[5:]
g = [x.strip() for x in g]
h = []
for x in g:
xx = x.split()
for xxx in xx:
if xxx[0] != '[':
if len(xxx) == 17:
if xxx[-4:] in ['.png', '.gif', '.jpg']:
h = h + [xxx]
g = h
j = []
for x in g:
t = eval(x[:-7])
tt = time.strftime("%y%b%d-%H.%M.%S", time.gmtime(t))
# print x, t, tt
j = j + [tt + x[-4:]]
rn = "rename %s %s"
for x in range(len(j)):
j[x] = (os.path.abspath(g[x]), j[x])
j = [rn % x for x in j]
for x in j:
os.system(x)
Look, it renames 4chan timestamp-named images to at least a human-readable format. TRY/CATCH BLOCKS ARE FOR FAGGOTS THIS WORKS FINE FOR ME AS LONG AS YOUR FOLDER DOESN'T CONTAIN ANY IMAGES WITH A 17-CHARACTER FILENAME THAT DOESN'T EVAL TO A PROPER TIMESTAMP. os.path.join() to taste, and chill for two hours. Cut into slices. Serves 12.
1) You used Python. Python is clearly inappropriate for this task.
2) Your code looks like shit, learn to code; read SICP.
3) ``images,'' who the hell wants images here in /prog/?
4) Real men use timestamps internally (in their heads, that is), and convert real dates to timestamps.
Name:
Anonymous2007-12-07 11:53
>>1
Doesn't work fine, it is not platform independant. Also, the code is horrible. FAIL PROGRAMMER
Name:
Anonymous2007-12-07 12:29
>>1
for x in g:
xx = x.split()
for xxx in xx:
if xxx[0] != '[':
if len(xxx) == 17:
if xxx[-4:] in ['.png', '.gif', '.jpg']:
h = h + [xxx]
lol var names x, xx and xxx. LOL WHUT?
Also you have no comments except for a out commented debug line.
Clearly you are not an EXPERT PROGRAMMER
Name:
Anonymous2007-12-07 12:39
>>16
What? To the compiler, the actual name of a variable does not matter, and this should also be the case for an EXPERT PROGRAMMER
Name:
Anonymous2007-12-07 12:54
>>17
What? An expert programmer would think of a descriptive name before a bunch of "x"s. “Let us change our traditional attitude to the construction of programs. Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.”
Name:
Anonymous2007-12-07 13:18
>>18
Descriptive variables names??? They're for NOOB PROGRAMMERS
Name:
Anonymous2007-12-07 14:55
PROTIP: Make functions small enough so that variable names don't need to be descriptive.
Absolutely no reason to call external programs. Python seriously does bring out some bad programmers. ITS SO GOD DAMN EASY, sure, you still did it wrong.
>>35
actually, this works too:
(my$newname=$_)=~s/(\d+)(....)$/${\((gmtime$1\/1000)[5]+1900)}${\($mname[(gmtime$1\/1000)[4]])}${\((gmtime$1\/1000)[3])}-${\(join'.',map{sprintf'%2u',$_}reverse map{(gmtime$1\/1000)[$_]}0..2)}$2/;
Name:
Anonymous2007-12-09 16:24
>>34,35
I don't know if this is any shorter, but it was fun making it :)
$f=@ARGV[0]and$r=qr{\/(\d+).(jpg|png|gif)}and$a=join'',grep/$r/,glob"$f/*";
while($a=~/$r/g){($d,$e)=($1,$2)and$_=gmtime$d/1000;
m/ (\w{3})\s+(\d+) (\d+):(\d+):(\d+) \d{2}(\d{2})/;
$n=join'',$6,$1,(sprintf"%02d",$2),"-$3.$4.$5";
rename"$f/$d.$e","$f/$n.$e";
}
The bus driver looked strangely familiar as I dropped the coins into the interpreter and rebuild the damn thing bind Instead of singletons I mean are there people need to learn but falls short on performance and in maintainability For.