forked from hello-earth/cloudflare-better-ip
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { execSync } = require('child_process'); | ||
|
||
//https://zip.baipiao.eu.org/ | ||
function readAllFilenames(directoryPath) { | ||
// 读取目录内容 | ||
fs.readdir(directoryPath, (err, files) => { | ||
if (err) { | ||
console.error('读取目录出错: ', err); | ||
return; | ||
} | ||
|
||
// 遍历每个文件名并输出 | ||
files.forEach((file) => { | ||
const filename = path.basename(file,path.extname(file)) | ||
const fileNameWithFullPath = directoryPath+"/"+file; | ||
const country = filename.split("-")[0] | ||
const port = filename.split("-")[2] | ||
const cmd = `~/script/CloudflareST/CloudflareST -f ${fileNameWithFullPath} -o ${filename}.csv -tp ${port}`; | ||
console.log(cmd) | ||
|
||
try { | ||
const output = execSync(cmd); | ||
console.log(output.toString()); // 命令的输出 | ||
} catch (error) { | ||
console.error(`执行命令时发生错误: ${error}`); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
// 调用函数读取文件名 | ||
readAllFilenames('~/Downloads/txt'); |