-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathnothing.js
More file actions
59 lines (53 loc) · 1.59 KB
/
nothing.js
File metadata and controls
59 lines (53 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// import fs from "fs";
// import Path from "path";
// import util from "util";
// const readdir = util.promisify(fs.readdir);
// const mkdir = util.promisify(fs.mkdir);
// const stat = util.promisify(fs.stat);
// const extensions = new Set(); // Use Set to avoid duplicates
// async function getFileExtensions(filePath) {
// const extType = Path.extname(filePath);
// if (extType) {
// extensions.add(extType);
// } else {
// extensions.add("others");
// }
// }
// async function checkFileType(dir) {
// try {
// const files = await readdir(dir);
// for (const file of files) {
// const filePath = Path.join(dir, file);
// const stats = await stat(filePath);
// if (stats.isDirectory()) {
// await checkFileType(filePath);
// } else {
// await getFileExtensions(filePath);
// }
// }
// } catch (error) {
// console.error("Error:", error);
// }
// }
// async function createFolderWithExt(baseDir) {
// try {
// for (const extension of extensions) {
// const dirName = extension.startsWith(".")
// ? extension.slice(1)
// : extension;
// const folderPath = Path.join(baseDir, dirName);
// await mkdir(folderPath, { recursive: true });
// }
// } catch (error) {
// console.error("Error creating folders:", error);
// }
// }
// (async () => {
// const baseDir = "/home/bossadi/Desktop";
// // await checkFileType(baseDir);
// await createFolderWithExt(baseDir);
// console.log(
// "Folders created based on file extensions:",
// Array.from(extensions)
// );
// })();