Replace using Filename

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
mowgli_za

Replace using Filename

Post 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?
jring
Posts: 9
Joined: Tue Sep 23, 2003 3:13 am

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

Post 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:

A1-#=//path#/file.txt
B1-#=replace_string

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

etc.
etc...
etc.....

good-luck!

J-
mowgli_za

quotes in replace string

Post 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.
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Post 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
mowgli_za

quotes

Post 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

Cheers
mowgli
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Post 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

\x22
Post Reply