Drag and Drop Files for Data Entry and Syncing

My fiancé does product shots for a local plant shop in the area. She will have dozens of plants to shoot that result in hundreds of photos.

Part of the job is organizing and uploading them to google photos. This means she has been renaming hundreds of files individually. 😭

The system they have down is: {PLANT_NAME}{DETAIL?}{POT_SIZE}_{number}. So for any given plant it will have several 'product' shots and several 'detail' shots taken for it.

A simple script but going to save hours of data entry!

Download Link

code
const fs = await npm("fs");
const plantName = await arg("Enter a plant name:");
const potSize = await arg("Enter pot size: ");
const shotType = await arg("Is this product or detail?", ["product", "detail"]);
const photos = await drop("Drop your images");
console.log(photos);
let renamePhotoToDirectory = (path, plantName) => {
// going to be a env variable
let targetDirectory = "/Users/zac/Desktop/photops/photos";
let photoPath = `${targetDirectory}/${plantName}`;
fs.rename(path, photoPath, (err) => {
if (err) return console.log("there was an error: ", err);
console.log("selectedFiles renamed");
});
};
photos.map((plant, index) => {
if (shotType === "detail") {
renamePhotoToDirectory(
plant.path,
`${plantName}Detail${potSize}_${index + 1}.png`
);
} else {
renamePhotoToDirectory(plant.path, `${plantName}${potSize}_${index + 1}.png`);
}
});