JSFiddle - React, Tailwind, and code Playground
by Sayantan Das
Babel + JSX
const products = [
'BMBCHU001',
'BMBCHU002',
'BMBCHU003',
'BMBCHU004',
'BMBCHU005',
'BMBCHU006',
'BMBCHU007',
'BMBCHU008',
'BMBCHU009',
'BMBCHU00A',
];
const sizes = [
{
dimension: '180x240',
prefix: '@1x'
},
{
dimension: '360x480',
prefix: '@2x'
},
{
dimension: '720x960',
prefix: '@3x'
},
];
const filenames = [{
existing: 'b.jpg',
new: 'back'
},
{
existing: 'f.jpg',
new: 'front'
},
{
existing: 's.jpg',
new: 'side'
},
];
const command = [];
const script = () => {
products.forEach((product) => {
sizes.forEach((size) => {
filenames.forEach((filename) => {
command.push(`mv ./${product}/${size.dimension}/${filename.existing} ./${product}/${filename.new}${size.prefix}.jpg`);
});
command.push(`rm -r ./${product}/${size.dimension}`)
})
})
}
script();
console.log(JSON.stringify(command));