From 97dbbb612b26df930bb549f4d534549ac827887b Mon Sep 17 00:00:00 2001 From: adb-sh Date: Mon, 23 Jan 2023 21:33:41 +0100 Subject: [PATCH] filter --- filterPictureData.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 filterPictureData.js diff --git a/filterPictureData.js b/filterPictureData.js new file mode 100644 index 0000000..667df69 --- /dev/null +++ b/filterPictureData.js @@ -0,0 +1,30 @@ + +const source = './Picturedata'; +const destination = './PicturedataFiltered'; +const picturesPath = './Pictures_1024_768'; +const labelsPath = './Labels_1024_768'; + +await Deno.remove(destination, { recursive: true }); +Deno.mkdir(destination); +Deno.mkdir(`${ destination }/${ labelsPath }`); +Deno.mkdir(`${ destination }/${ picturesPath }`); + +for await (const category of Deno.readDir(`${ source }/${ labelsPath }`)) { + Deno.mkdir(`${ destination }/${ labelsPath }/${ category.name }`); + Deno.mkdir(`${ destination }/${ picturesPath }/${ category.name }`); + for await (const label of Deno.readDir(`${ source }/${ labelsPath }/${ category.name }`)) { + try { + console.log(copy `${ source }/${ picturesPath }/${ category.name }/${ label.name }`); + await Deno.copyFile( + `${ source }/${ picturesPath }/${ category.name }/${ label.name.replace('.png', '.jpg') }`, + `${ destination }/${ picturesPath }/${ category.name }/${ label.name.replace('.png', '.jpg') }`, + ); + await Deno.copyFile( + `${ source }/${ labelsPath }/${ category.name }/${ label.name }`, + `${ destination }/${ labelsPath }/${ category.name }/${ label.name }`, + ); + } catch (e) { + console.log('label missmatch found', e); + } + } +}