sree161 Posted April 25, 2017 Share Posted April 25, 2017 is there any method to copy text from existing notepad to new notepad???? i have many lines of text in one note pad. i need to copy one line into a notepad and close it. i need to copy 2nd line into another notepad and close it. Is there any way to do it?? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 25, 2017 Moderators Share Posted April 25, 2017 Yes. Look at FileRead, ClipGet, and ClipPut in the help file. There are a number of ways to skin that particular cat; all of them with examples in the help file. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
sree161 Posted April 25, 2017 Author Share Posted April 25, 2017 Thanks as i am new to autoit i dont know much.....i will go through them and get back for further quires... Link to comment Share on other sites More sharing options...
sree161 Posted April 25, 2017 Author Share Posted April 25, 2017 do i need to open that file to be read.....?? Link to comment Share on other sites More sharing options...
sree161 Posted April 25, 2017 Author Share Posted April 25, 2017 in the help program they are creating a temp file to read data from....but i already have a file with data from which it should be read.......how can i read data from specific file on my local. i tried this by giving location of my local at which data is there but no use...kindly assist me. #include <FileConstants.au3> #include <MsgBoxConstants.au3> $FileRead = FileRead("C:\Users\asdf\Desktop\not.txt") MsgBox(0, "OTPT", "$FileRead") Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 25, 2017 Moderators Share Posted April 25, 2017 (edited) 1. FileRead will open the file to read it. If you are doing a lot or repetitive steps in a file, you can use FileRead, so your script is not constantly opening and closing the file in question 2. Take off the quotes around $FileRead in your msgbox Edited April 25, 2017 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
sree161 Posted April 25, 2017 Author Share Posted April 25, 2017 i tried it and i am not getting any ouput in msg box... do i need to enter any specific count value...because my text to be copied is in alpha numeric format?? code used: #include <FileConstants.au3> #include <MsgBoxConstants.au3> $FileRead = FileRead("C:\Users\asdf\Desktop\not.txt") MsgBox(0, "OTPT", $FileRead) not.txt contains: 1.xxxxxxxxxxxxxxx 2.xxxxxxxxxxxxxxx 3.xxxxxxxxxxxxxxx 4.xxxxxxxxxxxxxxx 5.xxxxxxxxxxxxxxx Link to comment Share on other sites More sharing options...
Skysnake Posted April 25, 2017 Share Posted April 25, 2017 I am confused. Do you want to copy not.txt to a new text file on disk? Or do you want to read the contents of file not.txt and then... paste it into another text file? Much of muchness it seems. First solution would be FileCopy ; Copy Au3 files in the temporary directory to a new folder/directory called Au3Files. FileCopy("c:\myautoit\not.txt", "c:\myautoit\new.txt", $FC_OVERWRITE + $FC_CREATEPATH) sree161 1 Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
sree161 Posted April 25, 2017 Author Share Posted April 25, 2017 but i wanted to copy specific data from existing file to a new one. so i thought if i could first read the specific data in the file, i could copy the same data. Any other ways to proceed.?? Link to comment Share on other sites More sharing options...
Skysnake Posted April 25, 2017 Share Posted April 25, 2017 What specific data? How do you identify that specific data? Post a sample? Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
sree161 Posted April 25, 2017 Author Share Posted April 25, 2017 ya like i have 5 lines in a notepad. i want to copy line 1 to one notepad and save it. line 2 to notepad2 and save it. but all these should not make changes in master notepad. Link to comment Share on other sites More sharing options...
Skysnake Posted April 25, 2017 Share Posted April 25, 2017 (edited) Still no example. Will it always be line 1? Where does line 1 go? to new1.txt? and line 2? Will it always be line 2? Where does it go? Also into new1.txt or into new2.txt? Copy without changing the source is really not a problem. The problem is identifying the exact data to copy, and then the destination. Have you looked in the Help file under FileReadLine ? Your questions sound something like "I don't know where I'm going but I hope to be there soon..." You need help, be more specific Edited April 25, 2017 by Skysnake Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
sree161 Posted April 25, 2017 Author Share Posted April 25, 2017 To be more specific my master notepad contains: 1.xxxxxxxxxxxxxxxxxxx 2.xxxxxxxxxxxxxxxxxxxxxxxxxx 3.xxxxxx 4.xxxxxxxxx 5.sadfhhshakj These are fixed and won't keep changing. Now i want to copy "1.xxxxxxxxxxxxxxxxxxx" to new1.txt "2.xxxxxxxxxxxxxxxxxxxxxxxxxx" to new2.txt and so on till line 5. Link to comment Share on other sites More sharing options...
sree161 Posted April 25, 2017 Author Share Posted April 25, 2017 can ClipPut and ClipGet be helpful ??? if yes how can i i use them?? how can i clip specific data from text file Link to comment Share on other sites More sharing options...
Gianni Posted April 25, 2017 Share Posted April 25, 2017 is there any reason you want use notepad ? you can read from a master file and write lines in new files directly #include <FileConstants.au3> Local $sLineRead = "", $x = 0 Local $sFilePath = "MasterFile.txt" ; Open the file for reading and store the handle to a variable. Local $hFileOpen = FileOpen($sFilePath, $FO_READ) Do ; Read a line from the file using the handle returned by FileOpen. $sLineRead = FileReadLine($hFileOpen) If @error Then Exit ; if no more lines in master file then exit $x += 1 ; write previously read line to a new file FileWrite("NewFile" & $x & ".txt", $sLineRead) Until @error ; if problem on writing then end sree161 and SkysLastChance 2 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
sree161 Posted April 26, 2017 Author Share Posted April 26, 2017 There is no specific reason for using notepad. Anyways thanks for helping me.....i am able to get the text i want Thank you very much Link to comment Share on other sites More sharing options...
sree161 Posted April 26, 2017 Author Share Posted April 26, 2017 (edited) Hi all Now i am trying to append text to the notepad while creating itself. I am using FileWriteLine() to append text Below is the program i used. #include <FileConstants.au3> Local $sLineRead = "", $x = 0 Local $sFilePath = "C:\Users\asdf\Desktop\not.txt" Local $hFileOpen = FileOpen($sFilePath, $FO_READ) Do $sLineRead = FileReadLine($hFileOpen) If @error Then Exit $x += 1 FileWrite($sLineRead & $x & ".txt", $sLineRead) FileWriteLine($sLineRead) FileWriteLine($sLineRead, "Line1:") FileWriteLine($sLineRead, "Line2:") FileWriteLine($sLineRead, "Line3:") FileWriteLine($sLineRead, "Line4:") Until @error ; i am getting output but it is creating 2 files. one is .txt file and other with no extension(file format). Is my logic right?? Is there any other command to append text.?? Kindly help Edited April 26, 2017 by sree161 wrong location Link to comment Share on other sites More sharing options...
Subz Posted April 26, 2017 Share Posted April 26, 2017 You can try: #include <File.au3> ;~ Path for New1.txt, New2.txt etc... Local $sFileSave = @ScriptDir ;~ File Name to Read Local $sFileRead = @ScriptDir & "\Notepad.txt" Local $aFileRead, $hFileOpen _FileReadToArray($sFileRead, $aFileRead) For $i = 1 To $aFileRead[0] ;~ This will create the new file + path (if it doesn't exist), using append mode $hFileOpen = FileOpen($sFileSave & "\New" & $i & ".txt", 9) ;~ Write line to new file with new line at the end FileWrite($hFileOpen, $aFileRead[$i] & @CRLF) ;~ Close the File FileClose($hFileOpen) Next sree161 and SkysLastChance 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now