Skip to content

Instantly share code, notes, and snippets.

@sjardim
Last active October 31, 2019 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjardim/0cf11af3d7d696155aade9e73ae1e7d2 to your computer and use it in GitHub Desktop.
Save sjardim/0cf11af3d7d696155aade9e73ae1e7d2 to your computer and use it in GitHub Desktop.
This Python script will move the files of the current folder into the folder structure according to a defined structure.
import shutil
import os
# This script will move the files of the current folder into the folder structure according to the FoldersMap.
# detect the current working directory
currentFolder = os.getcwd()
filePath = currentFolder
FoldersMap = {
'_logo_hrz_fc_cmyk' : 'Horizontal Logo/Full-Color/CMYK',
'_logo_hrz_fc_c-pms': 'Horizontal Logo/Full-Color/PANTONE',
'_logo_hrz_fc_u-pms': 'Horizontal Logo/Full-Color/PANTONE',
'_logo_hrz_blk_cmyk': 'Horizontal Logo/Black/CMYK',
'_logo_hrz_wht_cmyk': 'Horizontal Logo/White/CMYK',
'_logo_vrt_fc_cmyk' : 'Vertical Logo/Full-Color/CMYK',
'_logo_vrt_fc_c-pms': 'Vertical Logo/Full-Color/PANTONE',
'_logo_vrt_fc_u-pms': 'Vertical Logo/Full-Color/PANTONE',
'_logo_vrt_blk_cmyk': 'Vertical Logo/Black/CMYK',
'_logo_vrt_wht_cmyk': 'Vertical Logo/White/CMYK',
'_logo_hrz_fc_rgb' : 'Horizontal Logo/Full-Color/RGB',
'_logo_hrz_blk_rgb': 'Horizontal Logo/Black/RGB',
'_logo_hrz_wht_rgb': 'Horizontal Logo/White/RGB',
'_logo_hrz_fc_web' : 'Horizontal Logo/Web Image',
'_logo_hrz_blk_web': 'Horizontal Logo/Web Image',
'_logo_hrz_wht_web': 'Horizontal Logo/Web Image',
'_logo_vrt_fc_rgb' : 'Vertical Logo/Full-Color/RGB',
'_logo_vrt_blk_rgb': 'Vertical Logo/Black/RGB',
'_logo_vrt_wht_rgb': 'Vertical Logo/White/RGB',
'_mark_fc_cmyk' : 'Project Mark/Full-Color/CMYK',
'_mark_fc_c-pms': 'Project Mark/Full-Color/PANTONE',
'_mark_fc_u-pms': 'Project Mark/Full-Color/PANTONE',
'_mark_blk_cmyk': 'Project Mark/Black/CMYK',
'_mark_wht_cmyk': 'Project Mark/White/CMYK',
'_mark_fc_rgb' : 'Project Mark/Full-Color/RGB',
'_mark_blk_rgb': 'Project Mark/Black/RGB',
'_mark_wht_rgb': 'Project Mark/White/RGB',
}
files = os.listdir(filePath)
for f in files:
for key, value in FoldersMap.iteritems():
if key in f.lower():
folder = value
if not os.path.exists(folder):
os.makedirs(folder)
print("Folder created: " + folder)
shutil.move(f, filePath + '/' + folder)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment