PORTFOLIO_SCRAPING_EHD_RENAME_AND_MOVE

In [1]:
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)
/Volumes/EHD_8/EHD_7/ /Volumes/EHD_8/EHD_7/EHD_7_ALL/
In [21]:
# # BEFORE
# directory_in_str = '/Volumes/EHD_7/__pre2011/'
# destination = '/Volumes/EHD_7/__pre2011/__pre2011_ALL/'
In [1]:
# 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)
In [16]:
print(directory_in_str)
for subdir, dirs, files in os.walk(directory_in_str):
    for file in files:
        print(file)
/Volumes/EHD_7/__2017mac/
.DS_Store
In [14]:
testing = 'thisisaverylongtextstring'
testing[-100:]
Out[14]:
'thisisaverylongtextstring'
In [ ]: