feat: 获取最新文件夹问题修复

main
lichaojun 1 year ago
parent 80e9d634c3
commit 23acd1cd59

@ -2,7 +2,7 @@ const config = {
//基础公共配置
base: {
// 指定要查找的目录
directoryPath: 'C:/Users/Administrator/Desktop/test',
directoryPath: 'E:/商品资料汇总/商品资料(1051-1100)',
/**
* 图片文件夹路径
* 1. 配置文件中inputDir为空

@ -15,6 +15,7 @@ const getInputDir = () => {
// 获取该文件夹下最新创建的文件夹作为工作目录
const getLatestFolder = (directory) => {
let currentInputDir = null;
let latestTime = 0;
// 读取指定目录
fs.readdirSync(directory, { withFileTypes: true }).forEach((file) => {
@ -22,9 +23,7 @@ const getLatestFolder = (directory) => {
const folderPath = path.join(directory, file.name);
const stats = fs.statSync(folderPath);
const creationTime = stats.birthtimeMs; // 获取创建时间
// 找到最新创建的文件夹
let latestTime = 0;
if (creationTime > latestTime) {
latestTime = creationTime;
currentInputDir = folderPath;

Loading…
Cancel
Save