Replacing date string with current date and saving

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
MoGoo
Posts: 2
Joined: Mon Jun 02, 2003 7:37 pm

Replacing date string with current date and saving

Post by MoGoo »

Hi,

I'm rather new to TextPad and have read through some postings and help, but can't seem to come across a solution to the following:

I'd like to open an exiting file, find a known date (yyyymmdd), replace that date with the current date, then save the file as filenameyyyymmdd.txt where yyyymmdd is the current date.

I was able to record a macro that opened the file, found the date, but can't seem to figure out how to get the current date into the Search | Replace window.

I'll execute this from vbs file, and do know that I can set NewDate = but can I paste NewDate in the Replace window or something like that?

Sorry if this seems rather lame and ignorant :oops: - but any suggestions would be appreciated very much. :D

MoGoo
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Have you tried Edit - Insert - Date or Edit - insert - Short Date?

Might not be the date format you prefer....
MoGoo
Posts: 2
Joined: Mon Jun 02, 2003 7:37 pm

Post by MoGoo »

Thanks for the suggestion, the edit-insert seems like a starting point if I can get the format to yyyymmdd.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

You wrote:
if I can get the format to yyyymmdd.
Two approaches:
========================
1. Change the format of the system date:

If you have a Windows system, open the Control Panel.
Double click on Regional Settings
Goto the tab for date
Go to the section for Short Date
Change setting to yyyyMMdd
Click on Apply
Check the Short Date sample in the field above
Click on OK

Note that this will affect the appearance of Date in most other applications also.
=============================
2. Use Regular Expressions to change format after doing Insert.

The search and replace strings will depend on your existing format but might look something like this:

====
Search for ([0-1][0-9])/([0-3][0-9])/(20[0-9][0-9])

Replace with \3\1\2
====

NOTE:The regex sample above is unchecked, untested, first pass, crude, basic, not modified for TextPad syntax. For example, every parenthesis symbol needs to be prefaced with \.
======================

Hope this helps
Hope this was helpful.............good luck,
Bob
Post Reply