-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixnames.ts
53 lines (42 loc) · 1.36 KB
/
fixnames.ts
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
import {promises} from 'fs'
import { reencodeComponent } from './WikiDot';
(async function() {
const wikis = await promises.readdir('./storage/')
for (const wiki of wikis) {
try {
const pages = await promises.readdir(`./storage/${wiki}/files/`)
for (const page of pages) {
const fileList = await promises.readdir(`./storage/${wiki}/files/${page}`)
for (const file of fileList) {
const reencoded = reencodeComponent(file)
if (reencoded != file) {
console.log(`Renamed ${file} to ${reencoded}`)
await promises.rename(`./storage/${wiki}/files/${page}/${file}`, `./storage/${wiki}/files/${page}/${reencoded}`)
}
}
}
} catch(err) {
console.error(err)
}
}
})();
(async function() {
const wikis = await promises.readdir('./storage/')
for (const wiki of wikis) {
try {
const pages = await promises.readdir(`./storage/${wiki}/meta/files/`)
for (const page of pages) {
const fileList = await promises.readdir(`./storage/${wiki}/meta/files/${page}`)
for (const file of fileList) {
const reencoded = reencodeComponent(file)
if (reencoded != file) {
console.log(`Renamed ${file} to ${reencoded}`)
await promises.rename(`./storage/${wiki}/meta/files/${page}/${file}`, `./storage/${wiki}/meta/files/${page}/${reencoded}`)
}
}
}
} catch(err) {
console.error(err)
}
}
})();