Replace using Filename

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

mowgli_za

Replace using Filename

Postby mowgli_za » Thu Oct 23, 2003 11:32 pm

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: 18
Joined: Tue Sep 23, 2003 3:13 am

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

Postby jring » Sun Oct 26, 2003 10:21 pm

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

Postby mowgli_za » Fri Nov 14, 2003 1:08 am

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: 2136
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Postby DataMystic Support » Mon Nov 17, 2003 6:52 am

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
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

mowgli_za

quotes

Postby mowgli_za » Mon Nov 17, 2003 10:52 pm

"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: 2136
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Postby DataMystic Support » Tue Nov 18, 2003 8:06 am

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
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest