@@ -30,8 +30,8 @@ async function extractArchives() {
3030 }
3131
3232 // 确保目标目录存在
33- if ( ! fs . existsSync ( destDir ) ) {
34- console . error ( `目标目录不存在: ${ destDir } ` ) ;
33+ if ( ! destDir ) {
34+ console . error ( '未设置目标目录' ) ;
3535 return ;
3636 }
3737
@@ -41,6 +41,10 @@ async function extractArchives() {
4141 return ;
4242 }
4343
44+ if ( ! fs . existsSync ( destDir ) ) {
45+ console . log ( `目标目录不存在,创建: ${ destDir } ` ) ;
46+ fs . mkdirSync ( destDir , { recursive : true } ) ;
47+ }
4448
4549 // 读取目录并过滤出 .7z 文件
4650 const files = await readdir ( srcDir ) ;
@@ -62,15 +66,15 @@ async function extractArchives() {
6266 await unpack ( srcPath , destDir ) ;
6367 console . log ( `已解压 ${ file } 到 ${ destDir } ` ) ;
6468
65- // 重命名
66- const newName = path . basename ( file , '.7z' ) ;
67- const destPath = path . join ( destDir , newName ) ;
69+ // // 重命名
70+ // const newName = path.basename(file, '.7z');
71+ // const destPath = path.join(destDir, newName);
6872
69- // 将newName中的@替换为_
70- const newName2 = newName . replace ( '@' , '_' ) ;
71- const newPath = path . join ( destDir , newName2 ) ;
72- fs . renameSync ( destPath , newPath ) ;
73- console . log ( `已重命名 ${ destPath } 为 ${ newPath } ` ) ;
73+ // // 将newName中的@替换为_
74+ // const newName2 = newName.replace('@', '_');
75+ // const newPath = path.join(destDir, newName2);
76+ // fs.renameSync(destPath, newPath);
77+ // console.log(`已重命名 ${destPath} 为 ${newPath}`);
7478
7579 } catch ( error ) {
7680 console . error ( `解压 ${ file } 失败:` , error ) ;
0 commit comments