append to txt windows

1

I want to append small snippets of text to txt files.

If someone has a system for this, feel free to post it. I'm trying to create it.

At http://sourceforge.net/p/launchy/discussion/451015/thread/abba414b there was a discussion on this using Launchy (which I already did use - perfect).

You add a vbs script to a folder that Launchy indexes and then just hit

at tab "my things in the file" enter

and the job is done.

scritps comes here

at.vbs

Const ForAppending = 8
Dim strTextFile
Set objArgs = WScript.Arguments
strTextFile = "C:\home\todo.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strTextFile) Then
    Set objFile = objFSO.OpenTextFile(strTextFile, ForAppending)
Else
    Set objFile = objFSO.CreateTextFile(strTextFile)
End If
objFile.WriteLine objArgs(0)
objFile.Close

Problem: I need the qoutes around my entry. Would be better if I did not.

I found this script after:

  1. googling Append txt windows
  2. reading http://lifehacker.com/284127/take-launchy-beyond-application-launching
  3. reading http://benkraal.wordpress.com/2007/05/16/launchy-append-text-to-a-file-from-anywhere/
  4. landing on the sourceforge discussion linked above

Bonus if I'm able to change the path of the txt file say from \Dropbox\FolderA to \Dropbox\FolderB and the script still be intact.

user1603548

Posted 2014-07-10T21:06:53.170

Reputation: 484

haven't used launchy much as it seemed to miss out indexing things I needed when I tried it. But you should know echo linetoappend >>c:\blah\file.txt is a command you can run from cmd(start...run..cmd<ENTER>)that appends a line to a file. – barlop – 2014-07-10T22:57:23.520

You might want the vbs file to take 2 parameters one being the filename, the other being the line to append. The person at that link wanted just one parameter, and so multiple scripts so called with different names, each taking one parameter. He also wrote one with two parameters. – barlop – 2014-07-10T23:09:26.647

This link has the path strTextFile = "C:\home\todo.txt" it's not clear what you want to change there. Just change it – barlop – 2014-07-10T23:13:25.480

Answers

0

To elude double quotes around your entry, i.e. to hit at my things in the file instead of at "my things in the file" you may use next code snippet in place of objFile.WriteLine objArgs(0):

strResult = ""
For ii = 0 to objArgs.Count - 1
   strResult = strResult & CStr( objArgs( ii)) & Space( 1)
Next
objFile.WriteLine Rtrim( strResult)

JosefZ

Posted 2014-07-10T21:06:53.170

Reputation: 9 121