mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 05:46:00 +00:00
32 lines
813 B
JavaScript
32 lines
813 B
JavaScript
|
const fs = require('fs');
|
||
|
const path = require('path');
|
||
|
const glob = require('glob');
|
||
|
|
||
|
// 源路径和目标路径
|
||
|
const sourcePattern = './storage/playwright/tests-report-blob/blob-*/*';
|
||
|
const targetDir = './storage/playwright/tests-report-blob/';
|
||
|
|
||
|
// 确保目标目录存在
|
||
|
fs.mkdirSync(targetDir, { recursive: true });
|
||
|
|
||
|
// 使用 glob 模块匹配文件
|
||
|
glob(sourcePattern, (err, files) => {
|
||
|
if (err) {
|
||
|
console.error('Error matching files:', err);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// 移动每个文件
|
||
|
files.forEach((file) => {
|
||
|
const targetFile = path.join(targetDir, path.basename(file));
|
||
|
|
||
|
fs.rename(file, targetFile, (err) => {
|
||
|
if (err) {
|
||
|
console.error(`Error moving file ${file}:`, err);
|
||
|
} else {
|
||
|
console.log(`Moved file ${file} to ${targetDir}`);
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
});
|