Computing.Net > Forums > Programming > batch to edit a txt file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch to edit a txt file

Reply to Message Icon

Name: kirby
Date: May 9, 2007 at 12:26:48 Pacific
OS: XP
CPU/Ram: n/a
Product: n/a
Comment:

Need help writing a batch that will open a txt file, find a date (that is in an http address), then change that date to current. Possible?



Sponsored Link
Ads by Google

Response Number 1
Name: jongray
Date: May 9, 2007 at 14:22:43 Pacific
Reply:

Possible, not with batch files though. You want HTML Applications. You should give me an idea of what you want to do and I might be able to help you better.


0

Response Number 2
Name: Mechanix2Go
Date: May 10, 2007 at 01:11:53 Pacific
Reply:

#1 is right; a BAT won't work. Try:

http://golden-triangle.com/change91...


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 3
Name: IVO
Date: May 10, 2007 at 06:37:37 Pacific
Reply:

Maybe that is possible even by a batch using

Set VAR=%VAR:<old date>=<new date>%

The key point is the structure of the date and if its value is known.


0

Response Number 4
Name: kirby
Date: May 10, 2007 at 08:26:55 Pacific
Reply:

Well, the txt file is an html source page that has date specific links that are referrenced to outside links. Was looking for a better way to update those rather than tedious, daily manual update.


0

Response Number 5
Name: IVO
Date: May 10, 2007 at 08:53:52 Pacific
Reply:

A sample of the links to be modified may help to better understand.


0

Related Posts

See More



Response Number 6
Name: kirby
Date: May 10, 2007 at 10:07:22 Pacific
Reply:

Some are a href......org/070509.html - Some are img src.......com/070509.gif, where the outside links change their date format daily. Was hoping there was a quick and dirty to find the dates in my source file and update them to current date. Don't know if that can be done... Thanks guys for your time.


0

Response Number 7
Name: jongray
Date: May 10, 2007 at 22:03:37 Pacific
Reply:

I will show you an easy way to do this. First, for everything that you want the source to point to:


a href="#" ID="datepage"

You don't initally need a source, but you need the ID with a name in it for it to work. Same with anything with a tag:

img src="" ID="dateimage"

Now add this HTML Code to the BOTTOM of your page (but before the end </HTML> tag):

<script>
var now = new Date();
var day = now.getDate();
var month = now.getMonth()+1;
var year = now.getYear();
year = year.toString().charAt(2)+""+year.toString().charAt(3);
if(month < 10) { month = "0"+month; } if(day < 10) { day = "0"+day; }
function pointRef(objectid,filetype,editwhat,location) {
eval("document.all."+objectid+"."+editwhat+"=\""+location+year+month+day+"."+filetype+"\""); }

pointRef("datepage","html","href","http://blahblah.com/folder/");

pointRef("dateimage","gif","src","http://blahblah.com/folder/");

</script>


Those two pointRef things have all you will need to use to get the script working with different things. Try it out though, it works.

P.S.
When changing the folder, don't forget to include the / at the end or it won't work.


0

Sponsored Link
Ads by Google
Reply to Message Icon

play video file mfc progr... Reverse batch file needed



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: batch to edit a txt file

Batch to edit a text file www.computing.net/answers/programming/batch-to-edit-a-text-file/15894.html

Editing a txt file, renaming files www.computing.net/answers/programming/editing-a-txt-file-renaming-files/16242.html

Editing a Hex file using a Batch script www.computing.net/answers/programming/editing-a-hex-file-using-a-batch-script/19381.html