import os
import random
def recomposition(data_dir,batch_range):
path=data_dir
os.chdir(path)
oldNames=[]
newNames=[]
tempName=random.sample(range(1000000,1500000),len(batch_range))
for item in batch_range:
temp='data_batch_'+str(item)
oldNames.append(temp)
newNames=oldNames[:]
random.shuffle(newNames)
random.shuffle(newNames)
print oldNames
print newNames
for item in range(len(oldNames)):
tempPath=path+oldNames[item]
if os.path.exists(tempPath):
os.rename(oldNames[item],str(tempName[item]))
else :
print 'there is no path %s '% tempPath
for item in range(len(tempName)):
tempPath=path+str(tempName[item])
if os.path.exists(tempPath):
os.rename(str(tempName[item]),newNames[item])
else :
print 'there is no path %s '% tempPath