Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How to select any text and save that text directly in a .txt file in specified folder(in script like D:/backup/) and file name (filename.txt) should be asked upon pressing keyboard shortcut.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Many ways to go about doing this. The easiest would probably be to send Ctrl + c to store it in the clipboard, then write the clipboard contents to a text file:

^!p::
path= C:\
ClipSaved := ClipboardAll
Send ^c
clipwait
InputBox, location, save, Enter a filename:
FormatTime, TimeString,,MMM-dd-yyyy
FileAppend, %clipboard%, %path%\%location%-%TimeString%.txt
Clipboard := ClipSaved
ClipSaved=
return

Ctrl + Alt + p will trigger this. Let me know how it works I just hacked it together quickly.

share|improve this answer
    
@john - I want to set path manually in script code and only file name should be asked by dialog-box and extension should be fixed (.txt) with current date as a suffix of file like Filename-currentDate.txt. i want to give only filename and saving file would be like this estillproject-20/jan/10.txt –  metal gear solid Jan 20 '10 at 17:10
    
John T - Where are you? –  metal gear solid Jan 21 '10 at 7:38
    
@Jitendra I was asleep then at school, sorry. From what it looks like you want it to also make directories? Or am I mistaken? I've edited the code so you can put the path at the top, where it says path=, files will be saved in the format Filename-Jan-21-2010.txt if that's what you're after? –  John T Jan 21 '10 at 18:29
1  
sorry it's working i had not created a folder. You are my lifesaver. You are awesome. –  metal gear solid Jan 21 '10 at 18:55
    
You're welcome :) –  John T Jan 21 '10 at 19:22
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.