Create files using a list of filenames and adding content to each
I need to make a bunch of redirected pages as I recently updated my website which was previously using .html files and now all files are .aspx. I have a tab-delimited file containing a list of the original filenames and the corresponding new filename.
There seems to be a language in which I would have to create a file using the first column for the filename and insert the second column as its content with additional text for a 301 redirect.
Can anyone point me in the right direction as to which language might accomplish this? Also, if you can also specify the name of the method / function that I would use, I know where to start when creating the file.
I need to do this business many times and want to learn a new language (Perl, Python or whatever), but I just need to point in the right direction. I am using Windows XP for development.
Thank you for your time.
This can be done in a few lines of C #, if you are already working with aspx you can handle this in a codeblock on a dummy page.
System.IO.StreamReader myreader = new System.IO.StreamReader(Server.MapPath("~/Text.txt"));
while (!myreader.EndOfStream)
{
//9 is Ascii value of Tab bad idea to split if the second set of values might contain tabs but can reconstruct the data if inputString.length >2
string[] inputString = myreader.ReadLine().Split(char.ConvertFromUtf32(9).ToCharArray());
//construct the path to where you want to save the file, or if the filename is the full path all the better
System.IO.StreamWriter filemaker = new System.IO.StreamWriter(@"C:\" + inputString[0]);
filemaker.Write(inputString[1]);
filemaker.Close();
}
a source to share