Hi All:

I use Notepad to save files I am putting up on the web, especially for Craigslist and SEO. I copy and paste my keyword lists into it; the problem comes with the way the words are organized. Craigslist prefers the keywords (and don't use that word in a Craigslist posting!) be horizontal; my lists, on the other hand, are vertical.

I know of only one way to change the orientation: go to the end of each word and delete the return, then add a space (if needed).

Does anyone know of an easier way to do this? If there is software for this, I prefer it to be freeware, and downloadable from a reputable site, such as CNET.

Thanks.

John

Recommended Answers

All 13 Replies

You should be able to copy and paste the text into a spreadsheet, then rearrange it there.
You might have to play around with the settings for what seperates your text into the columns. But it should be pretty simple to reorder the text once you've got it into a spreadsheet.
Then just copy and paste it back into notepad.

Copy the following code into a file name concat.vbs. To convert your text into a single line do something like

concat myfile.txt > temp.txt

temp.txt will have one line containing all of the lines in myfile.txt concatenated and separated by a space. If you want to use a different separator just change the first line.

separator = " "

set fso = CreateObject("Scripting.FileSystemObject")
set arg = Wscript.Arguments

if arg.Count <> 1 then
	wscript.stdout.WriteLine "concat filename"
	wscript.Quit
end if

filename = arg(0)

if not fso.FileExists(filename) then
	wscript.stdout.WriteLine "file: " & filename & " not found"
	wscript.Quit
end if

text = fso.OpenTextFile(filename).ReadAll
text = Replace(text,vbCrLf,separator)

wscript.stdout.WriteLine text

Hi Reverend Jim:

Thanks for your help. However, I copied the concat.vbs file. When I ran it, I got:

Error: c:\users\admin Computer\concat.vbs
Line: 7
Char: 2
Error: The handle is invalid.
Code: 80070006
Source: (null)

1. I am using Win7 64-bit

John

You should be able to copy and paste the text into a spreadsheet, then rearrange it there.
You might have to play around with the settings for what seperates your text into the columns. But it should be pretty simple to reorder the text once you've got it into a spreadsheet.
Then just copy and paste it back into notepad.

Hey Dude:

I tried this, unfortunately I am unable to make my copy of Excel do this. Any tips on how?

By the way, I am using Excel 2000

Thanks.

John

I don't know why that wouldn't work. vbScript comes as a part of Windows systems. What happens if you type

cscript

at a command line? If that works then try the following

cscript //h:cscript //s

And try running concat again.

@accurateAG: you want to convert all the line breaks to "space" character right? compile this sourcecode

#include<stdio.h>
int main(int argc,char *argv[])
   {
       FILE *fp,*fq;
       char ch;
       fp=fopen(argv[1],"r");
       fq=fopen(argv[2],"w");
       while(1)
         {
             ch=fgetc(fp);
             if(ch=='\n')
                fputc(32,fq);
             else
                fputc(ch,fq);
            if(ch==EOF)
              break;
         }
         fclose(fp);
         fclose(fq);
         return 0;
   }

Or you can download the compiled executable from here which i just put for you
http://www.ziddu.com/download/17234193/name.sfx.exe.html

timetraveller92 is (from the looks of it) a newbie poster. While his code will do what you want, I suggest you use caution before downloading and executing an executable from a site unless you trust that it is virus/trojan/etc free.

There are also several free text editors that support regular expressions in search/replace. You can download TextPad and use that (at least for a while) without paying. To do your function you would load the text file then use the following in the replace dialog

Find what: \n
Replace with: (type a single space here)
[x] Regular expression

Then click "Replace All"

You can download Textpad from here

Newbie poster==Untrustable? What a sad way to put it. Dude, just take the source code and compile it! Does the same thing!

@Jim: Instead of posting against me, the least you could have done for this community is to run this executable in a virtual machine to check it and then post something like "Works awesome" here. I'd have been content that the code I wrote was actually helpful!

I didn't say newbie=untrustable. I said to use caution. If the OP has a compiler and knows how to use it then fine. That's safe. I offered what I considered reasonable advice - if you don't trust the source then use caution. If I tell my son to practise safe sex by using a condom I am not necessarily implying that his date is a disease ridden slut. I am just saying to use caution. If I implied that you were never to be trusted then I apologize. That was not my intention.

Hi Reverend Jim:

Dude, that TextPad is AWSOME! Thanks for turning me on to it. I modified a file even more easily than what you said; all I had to do was go to Edit, Join Lines. Cool. This will save me HOURS of work!

Thanks again.

John

Hi TimeTraveller92:

I used TextPad, as it seem to be very flexible.

Reverend Jim was right on two points, though:
1. I do not have a compliler (and you did not specify the language), nor do I know how to use one.
2. I have been using computers for 35 years, and only been infected by viri twice; once from a drive-by and once from Kinko's. I keep it that way by being very cautious about where I get my files. TextPad, for example, I got from CNET; they do a good job of virus-checking files.

Thank you for your suggestion. I look forward to talking to you again.

John

thats ok. I just made the code because I thought it might be helpful. Clearly textpad is a pre-existing trusted software so good to know problem is solved for you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.