Page 1 of 1

Replace using Filename

Posted: Thu Oct 23, 2003 11:32 pm
by mowgli_za
I would like to know whether TextPipe can do the following:

Given files //path1/aaa.txt, //path2/bbb.txt and //path3/ccc.txt (all in different folders, indicated by //path1..n), and an Excel spreadsheet with the following data:
//path1/aaa.txt | a1
//path2/bbb.txt | b2
//path3/ccc.txt | c3

[| represents column separator.]

I need to insert the value contained in column B, into the corresponding file contained in column A at the position where it matches a fixed pattern xxx. Can TextPipe insert the data into the files in one go?

You can accomplish your goal w/ a single batch file....

Posted: Sun Oct 26, 2003 10:21 pm
by jring
hmmmm...Since you want to use a unique replaced string on a pattern that is fixed across separate files, the only way I can imagine you could get from A-to-B in one go is by setting up a batch file.... If you use the below string, making only adjustments for:

1. Path to your textpipe.exe
2. /S0=XXX (your search string)
3. /R=a1 (your replace string)

*save .txt file at .bat, double click, and stand back while tpp does its thing, this should get there fine.

you can setup the string in excel very easily with this simple formula:



C="""c:\program files\textpipe\textpipe.exe"""&" /Minimized /BS /S0=XXX /R="&B1&" /N- /T-"&" """&A1&""""&" /g /q"

Here is the actual switch that should go into the batch file.

"c:\program files\textpipe\textpipe.exe" /Minimized /BS /S0=XXX /R=a1 /N- /T- "//path1/aaa.txt" /g /q
"c:\program files\textpipe\textpipe.exe" /Minimized /BS /S0=XXX /R=b2 /N- /T- "//path2/bbb.txt" /g /q
"c:\program files\textpipe\textpipe.exe" /Minimized /BS /S0=XXX /R=c3 /N- /T- "//path2/bbb.txt" /g /q




quotes in replace string

Posted: Fri Nov 14, 2003 1:08 am
by mowgli_za
What if my replace string contains both spaces and quotes? How would I express this in the command line syntax?
Will the following work? (Note the replace string is "var foo = "bar";").

"C:\Program Files\TextPipe\TextPipe.exe" /Minimized /BS /S0="xxx" /R="var foo = "bar";" /N- /T-"/my/docs/doc1.txt" /g /q

Thanks a 10^9 in advance.

Posted: Mon Nov 17, 2003 6:52 am
by DataMystic Support
You need to enclose the ENTIRE parameter in quotes e.g.

"C:\Program Files\TextPipe\TextPipe.exe" /Minimized /BS "/S0=xxx" "/R=var foo = "bar";" /N- /T- "/my/docs/doc1.txt" /g /q


Posted: Mon Nov 17, 2003 10:52 pm
by mowgli_za
"C:\Program Files\TextPipe\textpipe.exe" /Minimized "/S0=brown fox" "/R=purple "mink"" /N- /T- "\pathname\filename.txt" /g /q

didn't work. The resultant document does not display the word "mink" in (double) quotes. Thankfully the programming language I'm using recognises single quotes as well. This works:

"C:\Program Files\TextPipe\textpipe.exe" /Minimized "/S0=brown fox" "/R=purple 'mink'" /N- /T- "\pathname\filename.txt" /g /q


Posted: Tue Nov 18, 2003 8:06 am
by DataMystic Support
I've tried a few things as well, and it appears DOS is a bit problematic when it comes to putting double quotes inside double quotes.

A final alternative is to use a hex escape code for the character