Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

rename.py

Name: Anonymous 2007-12-07 1:33


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.

Name: Anonymous 2007-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

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List