Skip to content

Instantly share code, notes, and snippets.

@ColinTalbert
Created February 7, 2020 00:10
Show Gist options
  • Save ColinTalbert/bc593effb788fcc73dfade6e1d58b1c6 to your computer and use it in GitHub Desktop.
Save ColinTalbert/bc593effb788fcc73dfade6e1d58b1c6 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### A quick and dirty script to copy the .wav files in a directory into a new directory with a flat structure.\n",
"#### While also skipping noise files."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"import shutil"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"dname = r\"G:\\NABat\\NGPNP_20190430\"\n",
"\n",
"out_dname = r\"G:\\NABat\\NGPNP_20190430_output\" "
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"d = Path(dname)\n",
"\n",
"out_d = Path(out_dname)\n",
"\n",
"if not out_d.exists():\n",
" out_d.mkdir()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"wavs = d.glob(\"**/*.wav\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for wav in wavs:\n",
" if not wav.parent.name == 'NOISE':\n",
" shutil.copy(str(wav), str(out_d.joinpath(wav.name)))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment