ksmplayedsongs/ksmplayedsongs.nim

28 lines
887 B
Nim

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 & playerName
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.write(path & "\\" & p2)
# KSM can only read Windows style line endings
f.write('\r')
f.write('\n')
finally:
close(f)
else:
quit("Error writing to file: " & outFileName)