Sign in to follow this  
Followers 0
olirav

Replace in text file

6 posts in this topic

#1 ·  Posted (edited)

I am building a small program that processes an directory of images and creates a basic html file for them

I have the code that gets the directory in the format:

1.jpg

2.jpg

and copies it to the clipboard. Then this script should process it (1st stage)

$bak = ClipGet()
$writefile = FileOpen ("C:\Website\images.html", 2)
    $FileContent=StringReplace($bak,".jpg", ".jpg"/>"&@CRLF)  
    FileDelete($writefile)  
    FileWrite($writefile,$FileContent)

However the new line (@crlf) doesn't work

I had previously got it working in word with these two find and replace searches (fairly slow)

.jpg -> .jpg"/>^l<img width="150" height="120" src="../image/

/image/^p -> /image/

(and a couple more to clean up, but those two are the important ones)

The regular expressions (From Word) are:

^l = manual line

^p = paragraph character

How can I use autoit to use these replace searches.

Oli

Edited by olirav

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Use ' instead "

Probably

StringReplace($bak,'.jpg"', '.jpg"/>'&@CRLF)
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Use ' instead "

Probably

StringReplace($bak,'.jpg', '.jpg"/>'&@CRLF)

Im afraid that only gives

1.jpg"/> 2.jpg"/> 3.jpg"/>

I need

1.jpg"/>
2.jpg"/>
3.jpg"/>

In the html file - still no line break

Edited by olirav

Share this post


Link to post
Share on other sites

Try @CR

or

@LF

What char do replicate new row in HTML?

I dont have problems when dooing it in notepad, dont see how it cant work in HTML.

With what program (editor) do you check that new row r correct or not?


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

Try @CR

or

@LF

What char do replicate new row in HTML?

I dont have problems when dooing it in notepad, dont see how it cant work in HTML.

With what program (editor) do you check that new row r correct or not?

I have just found out that the new line is working (I made the mistake of using firefox to view the file (forgot it was html not txt)

Thanks, I've got the rest to work now as well, thank you for helping me see my silly mistake.

oli

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0