<commit_before>#! /usr/bin/env node

var fs = require('fs');
var dirname = require('path').basename(__dirname);
var writer = require('m3u').extendedWriter();
var audioExtensions = require('audio-extensions');
var path = process.cwd();

if(!fs.existsSync(path)) return;

fs.readdirSync(path).forEach(function(file) {
	var ext = file.split('.')[1];

	if(audioExtensions.indexOf(ext) !== -1) {
		writer.file(file, 0, file);
	}
});

fs.writeFile(dirname + '.m3u', writer.toString(), function(err) {
	if(err) {
		return console.log(err);
	}<commit_msg>Get the last dirname from the folder path using regexp<commit_after>#! /usr/bin/env node

var fs = require('fs');
var writer = require('m3u').extendedWriter();
var audioExtensions = require('audio-extensions');
var path = process.cwd();
var dirname = path.match(/([^\/]*)\/*$/)[1];

if(!fs.existsSync(path)) return;

fs.readdirSync(path).forEach(function(file) {
	var ext = file.split('.')[1];

	if(audioExtensions.indexOf(ext) !== -1) {
		writer.file(file, 0, file);
	}
});

fs.writeFile(dirname + '.m3u', writer.toString(), function(err) {
	if(err) {
		return console.log(err);
	}
{'fraction_non_alphanumeric': 0.20726306465899025, 'fraction_numerical': 0.00974313551815766, 'mean_word_length': 5.208791208791209, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5127287', 'n_tokens_mistral': 411, 'n_tokens_neox': 398, 'n_words': 81}