ehd = 'EHD_8'
file_to_flatten = 'EHD_7'
directory_in_str = '/Volumes/{}/{}/'.format(ehd, file_to_flatten)
destination = '/Volumes/{}/{}/{}_ALL/'.format(ehd, file_to_flatten, file_to_flatten)
print(directory_in_str, destination)
# # BEFORE
# directory_in_str = '/Volumes/EHD_7/__pre2011/'
# destination = '/Volumes/EHD_7/__pre2011/__pre2011_ALL/'
# import os, time, shutil
# ## NOTE: Don't forget to make the _ALL folder within the file_to_flatten directory
# ehd = 'EHD_8_TOSHIBA_EXT'
# file_to_flatten = 'EHD_7'
# directory_in_str = '/Volumes/{}/{}/'.format(ehd, file_to_flatten)
# destination = '/Volumes/{}/{}/{}_ALL/'.format(ehd, file_to_flatten, file_to_flatten)
# for subdir, dirs, files in os.walk(directory_in_str):
# for file in files:
# filepath = subdir + os.sep + file
# time_stamp = 'no_ts_'
# try:
# stat = os.stat(filepath)
# time_stamp = time.strftime('%Y-%m-%d', time.localtime(stat.st_birthtime))
# except:
# print('----',stat.st_mtime)
# try:
# newname = filepath.split(directory_in_str)[1].replace('/', '__')
# newfilename = time_stamp + '_' + newname[-100:] + '__' +file
# newpath = destination + newfilename
# # print(len(newfilename), file)
# shutil.move(filepath, newpath)
# # print(filepath, newpath)
# except Exception as e:
# print(e)
print(directory_in_str)
for subdir, dirs, files in os.walk(directory_in_str):
for file in files:
print(file)
testing = 'thisisaverylongtextstring'
testing[-100:]