
January 25th, 2013, 08:55 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 1
Time spent in forums: 14 m 28 sec
Reputation Power: 0
|
|
|
File organisation
hi im trying to create a script that would allow for me to be able to have files automatically sorted in a folder.
there are a few things which i need to be carried out but there is one bit that i cant figure out, what i need to do is be able to get the first character of every file, i then need to create a folder for every unique value the closest i have come to so far is this:
import os
from os import listdir
import dircache
import sys
import shutil
import dircache
import glob
path = "C:\\Users\\hra\\Desktop\\fg"
dirList=os.listdir(path)
for fname in dirList:
print fname
myList = fname
[x[0] for x in myList]
print "my list = ", myList
fCounter = len(glob.glob1("C:\\Users\\hra\\Desktop\\fg","f*"))
mCounter = len(glob.glob1("C:\\Users\\hra\\Desktop\\fg","m*"))
bCounter = len(glob.glob1("C:\\Users\\hra\\Desktop\\fg","b*"))
#print "all files = ", countall
print "f = ", fCounter
print "m = ", mCounter
print "b = ", bCounter
|