batch file to create a .txt file

i need a batch file that will create a .txt file when clicked in a folder called C:\DateModified

click on create.bat
it creates a file in C:\DateModified\notes.txt

this is basically used to create a date stamp note.

it would be great if it would do an echo and allow me to add the note inside the cmd box that
shows up, but i do not know if that is possible?

also if it can auto name the file to today's date like,  2011-sept-17 would be awesome,
but do not think that it is fair to ask that with this question for only 500 points
if that can be done, let me know and i will post another question to provide more points for that
question to add file with today's date name.

Who is Participating?
Steve KnightConnect With a Mentor IT ConsultancyCommented:
BTW You can run that from a batch file if needed:

@Echo off
cscript //nologo writenote.vbs

Also in the last line, msgbox the word "TheNote" on the end should be "InputNote" to show what was added.  If you want to remove the confirmation just remove the whole msgbox line.

Can also write in just batch file but is much more prone to variations in date formats and the like.

The attached VBS has this corrected and also stops the process if you press Cancel or enter a blank string.
something like:
set /p note=Just one line: 
set filename=note_%date%_%time%.txt
echo %date%/%time% > %filename%
echo %note% >> %filename%

rem if you want to note more, enable this
rem notepad %filename%

Open in new window

webdottAuthor Commented:
that is almost it.

1. it does not create it as a .txt file,  it does not actually add the .txt to the file name

2. it names it as note_Sat , i need it to be like:  note_2011/09/17.txt

3. finally it adds the note like below attached;
hi tiday  09/17/2011_13:39:40.47.txt

Open in new window

any way to actuall get rid of the time inside the file so it looks like this:
hi today

Open in new window

4. and finally, i need it to create it in a specific folder like: C:\DateModified\
  this one creates it in it's self folder wherever it is located

this is nice that it is close to what i need.
thanks for that - it helps me get started.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Problem is, %date% on windows is regional different. Here, it is just, which is not good when sorting, but works. On the other hand, there are colons in time, which can't be in a filename.

This should work right:
set /p note=Just one line: 
set filename="note_%date%_%time%.txt"

set year=%date:~-4%
set month=%date:~-10,2%
set day=%date:~-7,2%
set second=%time:~-5,2%
set minute=%time:~-8,2%
set hour=%time:~-11,2%

set datetime=%year%%month%%day%_%hour%%minute%%second%
set filename=note_%datetime%.txt

echo %date% at %time% > %filename%
echo %note% >> %filename%

rem if you want to note more, enable this
rem notepad %filename%

Open in new window

Steve KnightIT ConsultancyCommented:
Here is an alternative approach.  It prompts for a string in a pop-up window using a VBScript dialog box, gets the date/time usign reliable methods within VBScript, and then outputs the file:

See article here of mine on why using %date% is dodgy for dates in batch files:
Dim TheDate, InputNote, fileOutput

REM TheDate is in YYYY-MM-DD format
TheDate = year(date) & "-" & right(100+month(date),2) & "-" & right(100+day(date),2)

InputNote = inputbox ("Please enter your note:", "Note entry for " & date)

Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set fileOutput = objFSO.CreateTextFile("C:\DateModified\" & TheDate & ".txt")
    fileOutput.WriteLine InputNote
Set objFSO = Nothing

msgbox "Thankyou. I have created file C:\DateModified\" & TheDate & ".txt for you with contents of " & chr(10) & TheNote

Open in new window

webdottAuthor Commented:
thanks - that is what i was looking for!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.