My code asks the user to input a file name. We’ll say we have 5 text files in directory “C:\Users\aUser\Desktop\myFolder”. These text files are named A, B, C, D, and E.
If the text file exists, then I would like to write over the contents with a script I’ve already made. If the text file does not exist, I would like to make one with the file name they inputted, and populate it [with the script I’ve already written].
Thanks for your help.
The way you explain it, it seems that the easiest workflow would be:
1) Delete the file if exists
Copy the script (I assume also a txt file) into the path:
FileCopy “U:\Script”, sPath
If you have the script in a string variable:
If the script is contained in an array, you can loop through the array and produce multiple writelines.
Don’t forget to reference the Microsoft Scripting Runtime library.