This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function slugify (text, ampersand = 'and') { | |
const a = 'àáäâèéëêìíïîòóöôùúüûñçßÿỳýœæŕśńṕẃǵǹḿǘẍźḧ' | |
const b = 'aaaaeeeeiiiioooouuuuncsyyyoarsnpwgnmuxzh' | |
const p = new RegExp(a.split('').join('|'), 'g') | |
return text.toString().toLowerCase() | |
.replace(/[\s_]+/g, '-') // Replace whitespace and underscore with single hyphen | |
.replace(p, c => | |
b.charAt(a.indexOf(c))) // Replace special chars | |
.replace(/&/g, `-${ampersand}-`) // Replace ampersand with custom word |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import os, time, shutil, sys | |
dir = sys.argv[1] | |
os.chdir(dir) | |
for f in os.listdir('.'): | |
ftime = time.gmtime(os.path.getmtime(f)) | |
ctime_dir = str(ftime.tm_year) '-' str(ftime.tm_mon) '-' str(ftime.tm_mday) | |
if not os.path.isdir(ctime_dir): | |
os.mkdir(ctime_dir) |