Script kiddies: Is there something which can perform this boring task

Soldato
Joined
27 Dec 2006
Posts
2,845
Location
Northampton
I need to update a text file for my website. The code is below:

Code:
<image>
		<thumb_path>test1/thumbs/2.jpg</thumb_path>
		<big_image_path>test1/images/2.jpg</big_image_path>
		<description>test image 2</description>
		
	</image>

What I want is for the changes to be done below but in sequence

Code:
<image>
		<thumb_path>test1/thumbs/2.jpg</thumb_path>
		<big_image_path>test1/images/2.jpg</big_image_path>
		<description>Image 2</description>
		
	</image>

<image>
		<thumb_path>test1/thumbs/3.jpg</thumb_path>
		<big_image_path>test1/images/3.jpg</big_image_path>
		<description>Image 3</description>
		
	</image>
 
Soldato
Joined
18 Oct 2002
Posts
8,016
If it is literally just removing the "test image" and replacing it with "Image" in the description tag, then you can do that in Notepad, using the Find & Replace:

Find:

<description>test image

Replace:

<description>Image
 
Soldato
OP
Joined
27 Dec 2006
Posts
2,845
Location
Northampton
Is that the only thing that will be in the file?

if so i can probably knock some command line thing up to do it for you.

yes please, i'm also finished with the first XML file but in future I will need a script command that will help me do this effortless and also reduce any errors

If it is literally just removing the "test image" and replacing it with "Image" in the description tag, then you can do that in Notepad, using the Find & Replace:

Find:

<description>test image

Replace:

<description>Image

No, not quite. From my OP, Images are sequenced i.e.

Code:
<image>
		<thumb_path>test1/thumbs/1.jpg</thumb_path>
		<big_image_path>test1/images/1.jpg</big_image_path>
		<description>Image 1</description>
		
	</image>

	
    <image>
		<thumb_path>test1/thumbs/2.jpg</thumb_path>
		<big_image_path>test1/images/2.jpg</big_image_path>
		<description>Image 2</description>
		
	</image>


    <image>
		<thumb_path>test1/thumbs/3.jpg</thumb_path>
		<big_image_path>test1/images/3.jpg</big_image_path>
		<description>Image 3</description>
		
	</image>

This will keep on going all the way to 200!
 
Soldato
Joined
21 Oct 2009
Posts
2,742
http://www.megaupload.com/?d=Q7MGGXZ0

just enter output file location first (with extension, ie. textfile.txt will save in exe location)
then enter the number of images you want, starts at image1

edit - if you need it to use other file locations and stuff i can edit that in, but that will output what you put above (assuming i didnt spell anything wrong ;))

edit again - i could have just uploaded the text file i made to test it :p oh well.
 
Last edited:
Associate
Joined
4 Mar 2007
Posts
315
Location
United Kingdom
is this to be run on the server or on your computer to later be uploaded on the server, if it's on the server I can just make you an xml parser that replaces the certain segments you require. if it's a desktop application then something as simple as VB could be used to achieve this.
 
Associate
Joined
7 Oct 2003
Posts
674
Location
Bournemouth
any dynamic code would be a piece of wotsits to do this... you coulld just write it into a loop.

Can happily supply an example in ASP or php if you want, email in trust :)
 
Associate
Joined
7 Oct 2003
Posts
674
Location
Bournemouth
<?php
$i = 1;
while ($i <= 200):
?>

<image>
<thumb_path>test1/thumbs/<?php echo $i;?>.jpg</thumb_path>
<big_image_path>test1/images/<?php echo $i;?>.jpg</big_image_path>
<description>Image <?php echo $i;?></description>
</image>
<?php
$i++;
endwhile;
?>
 
Soldato
Joined
12 Jan 2004
Posts
3,172
Location
Brighton
wait what, you can do that?

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<title>microtemplating demo</title>
		<script type="text/javascript" src="javascript/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="javascript/jquery-ui-1.8.1.custom.min.js"></script>
		<script type="text/javascript" src="javascript/jquery.tmpl.js"></script>
		<script type="text/template" id="imagetemplate">
			<image><thumb_path>test1/thumbs/${id}.jpg</thumb_path><big_image_path>test1/images/${id}.jpg</big_image_path><description>test image ${id}</description></image>		
		</script>
		<script type="text/javascript">
			$(document).ready(function($) {
				var counter = 0;
				while (counter ++ < 200)
					$('#imagetemplate')
						.tmpl({id : counter})
						.appendTo($('body'));
			});
		</script>
	</head>
	<body></body>
</html>

You can then select all and say "view source" and you will get your

Code:
<img><thumb_path>test1/thumbs/1.jpg</thumb_path><big_image_path>test1/images/1.jpg</big_image_path><description>test image 1</description><img>
etc...
 
Back
Top Bottom