Edit: Sorry I made the topic an forgot to change the title. Should be: "List Files in Folder With Ignore List" or something along those lines.
I'm a game server admin. What I want to do is generate a text file which will be used when I launch the server. An example of the text file I want to produce is here:
sv_mapcycle_add wizard ctf3
sv_mapcycle_add bloodgulch ctf3
Line 1 and 2 will be hard coded into the script. In fact, this section will have more lines but for this example, I've cut it down. Lines 3 and 4 are codes that add all maps to the server: wizard and bloodgulch. These are *.map files. Line 5, like lines 1 and 2, are to be hard coded.
The map files are in the \maps subdirectory of the game. What I'm looking to do, is create a batch file that will generate the above text. That is, getting a list of map files in the \maps directory and concatenating it with the proper text before and after. I also want to have the .map extension removed from the lists.
The \maps subdirectory has a few *.map files that aren't actual maps, in fact I don't know what they are. So, I would like to be able to allow for exclusions, which I will hard code as well. (i.e.: ui.map, sounds.map)
Note that this script will probably be saved somewhere in the Quick Launch folder and I want to specify the location of the output and the name of the file. It will be in a text file format.
If you can help me with this, thanks.
EDIT: I've found code that partially does what I want it to do. However, there are some problems:
On Error Resume Next
Dim fso, folder, files, NewsFile,sFolder
Set fso = CreateObject("Scripting.FileSystemObject")
sFolder = "C:\Users\Josh\Desktop\Maps\"
If sFolder = "" Then
Wscript.Echo "No Folder parameter was passed"
Set NewFile = fso.CreateTextFile(sFolder&"\test.txt", True)
Set folder = fso.GetFolder(sFolder)
Set files = folder.Files
For each folderIdx In files
NewFile.WriteLine("sv_mapcycle_add " & folderIdx.Name & " ctf3")
- I had to remove the first line with sv_name "MyServer", probably because of the fact that this has quotations in it. Otherwise the script wouldn't even run.
- the *.map extension is still shown. It needs to be removed.
- I need to allow for an exclusion file list. The files excluded will all be listed.