I\'m creating a function in pure-Lua to scan the files from a directory and put they on a another file.
The command I tryed was:
os.execute( \"dir /B C:
Most of the commands you listed appear to be shell commands that only work within a command prompt. Try running cmd.exe directly to see if you get a prompt, and if so, you can try passing commands to cmd.exe via the /c option. You could also try notepad without the start to see if that runs.
os.execute('cmd.exe /c dir /B C:\\> C:\\test.txt')
That works. Useing Linux-style commands in win is a bad idea at all =)
I just tested your code on my computer and it works correct (with my directories, of course). Maybe you are not getting the expected result because your directory
string is broken with an newline char, resulting in:
dir /B C:\Users\Fernando\workspace\Organizator2\s1 > C:\Users\Fernando\
workspace\Organizator2\temp.txt
The correct should be:
dir /B C:\Users\Fernando\workspace\Organizator2\s1 > C:\Users\Fernando\workspace\Organizator2\temp.txt
Please try changing the do end to:
local source = "C:\\Users\\Fernando\\workspace\\Organizator2\\s1"
local directory = ScanDirectory(source, "C:\\Users\\Fernando\\workspace\\Organizator2\\temp.txt")
Please try it with this syntax:
os.execute [["dir /B C:\Users\Fernando\workspace\Organizator2\s1 >
C:\Users\Fernando\workspace\Organizator2\temp.txt"]]
Please note that the backslash (\
) is not a special character in this case.
(Lua uses cstrings internally, sometimes it leads to some weird and amazing results :P)