ksmplayedsongs/ksmplayedsongs.nim

25 lines
780 B
Nim
Raw Normal View History

import os
echo("Input KSM directory")
let mainDir: string = readLine(stdin)
var playerName: string = ""
echo("If your ingame player name is not 'PLAYER' enter it now (otherwise press enter)")
playerName = readLine(stdin)
if playerName == "":
playerName = "PLAYER"
let userDir: string = mainDir & DirSep & "score" & DirSep & "PLAYER"
let outFileName: string = mainDir & DirSep & "songs" & DirSep & "Played.fav"
var f: File
if open(f, outFileName, fmWrite):
try:
for kind, path in walkDir(userDir, true):
if kind == pcDir:
let fullPath = userDir & DirSep & path
for k2, p2 in walkDir(fullPath, true):
if k2 == pcDir:
f.writeLine(path & DirSep & p2)
finally:
close(f)
else:
quit("Error writing to file: " & outFileName)