Skip to content

Instantly share code, notes, and snippets.

View poacosta's full-sized avatar
:atom:
ἐρευνητής

Pedro Orlando Acosta Pereira poacosta

:atom:
ἐρευνητής
View GitHub Profile
@poacosta
poacosta / create-files-by-extensions-given-a-path.py
Last active February 7, 2023 11:54
Create files by extensions given a path using Python
import os
EXTENSIONS = ['py', 'rb', 'cs', 'ex', 'js', 'go', 'rs', 'dart', 'php', 'sql']
def create_files_by_extension_given_a_filename(name, directory):
for extension in EXTENSIONS:
file = f"{name}.{extension}"
if os.path.exists(os.path.join(directory, file)):
print('{0}: already exists!'.format(file))
@poacosta
poacosta / create-dirs-by-filenames-given-a-path.py
Last active January 16, 2023 03:31
Create directories by file names given a path using Python
import os
def create_dirs_by_filenames(filenames, parent_dir):
mode = 0o777
for directory in filenames:
os.mkdir(os.path.join(parent_dir, directory), mode)
def get_filenames(path):