Dating a template file

Jul 12, 2008
286
0
Las Vegas, NV
I have a template that I have set to Read-Only for protection.

Is there a btm file that I could set up that would copy he template giving it

"todaysdate"(number the file sequence).btm

The "number being if I have several on the same date.

It can be done, can't it?

Regards,
Chuck Billow
 
May 20, 2008
11,424
99
Syracuse, NY, USA
On Mon, 13 Jun 2011 01:20:48 -0400, CWBillow <> wrote:

|I have a template that I have set to Read-Only for protection.
|
|Is there a btm file that I could set up that would copy he template giving it
|
|"todaysdate"(number the file sequence).btm
|
|The "number being if I have several on the same date.
|
|It can be done, can't it?

I don't know about the read-olny business; I suppose if you can read it, you can
copy it.

And I'm not 100% sure about exactly what you want to do ... but, how about

Code:
rem could start at 0
set i=1
do file in [wildcard description of templates]
	copy %file [destination\]%[_date]%i.btm
	set i=%@inc[%i]
enddo
 
Jul 12, 2008
286
0
Las Vegas, NV
Vince, I'm sorry, I was unclear, and I had a typo, and I'm way too new at this to be certain of what you are saying.

So: I have a file:

c:\form.txt

that I use, say, daily. So what I want to do is, whenever I would need it, "pull up" c:\form.txt and use it

BUT

not overwrite it (Hence the read-only state)

so I would save it today, say, as "frm061311.txt

So, in the code you propsed, it would read

Code:
rem could start at 0
set i=1
do file in C:\form.txt
    copy %file C:\%_date%i.txt
rem then U take off the read/only  
attrib -r c:\form.txt
   set i=%@inc[%i]
enddo
yes?

And the are for?

Chuck




On Mon, 13 Jun 2011 01:20:48 -0400, CWBillow <> wrote:

|I have a template that I have set to Read-Only for protection.
|
|Is there a btm file that I could set up that would copy he template giving it
|
|"todaysdate"(number the file sequence).btm
|
|The "number being if I have several on the same date.
|
|It can be done, can't it?

I don't know about the read-olny business; I suppose if you can read it, you can
copy it.

And I'm not 100% sure about exactly what you want to do ... but, how about

Code:
rem could start at 0
set i=1
do file in [wildcard description of templates]
    copy %file [destination\]%[_date]%i.btm
    set i=%@inc[%i]
enddo
 
May 20, 2008
3,515
4
Elkridge, MD, USA
Chuck:

I regularly use the technique of creating objects named with the current
date, with sequence numbers. For purposes of sortability I use the ISO-style
date (yyyymmdd), and number items starting with 000. Below is code you could
use (not tested, but barely changed from one I use for every new TCMD
build):


@echo off
setlocal
set d=%@left[8,%_datetime]
do n = 1000 to 1999
set dr=%[d]%@right[3,%n].txt
iff isfile %dr then
iterate
else
copy C:\form.txt %dr
attrib -r %dr
leave
endiff
enddo

A simpler method is to just just %_datetime.txt as your target name. This
guarantees unqiueness UNLESS you try to generate more than one target within
the same second. That's what I do to name my digital pictures - my camera
cannot take shoot faster.
--
Steve
 
May 20, 2008
11,424
99
Syracuse, NY, USA
On Mon, 13 Jun 2011 03:27:40 -0400, CWBillow <> wrote:

|Code:
|---------
|rem could start at 0
|set i=1
|do file in C:\form.txt
| copy %file C:\%_date%i.txt
|rem then U take off the read/only
|attrib -r c:\form.txt
| set i=%@inc[%i]
|enddo
|---------
|yes?

Don't you want to remove read_only from the **new** one?

If there's only one such file you don't need to loop (DO) through files. But if
you're going to want several copies of it per day, and run the batch file each
time you want a new one, then you'll need a way to keep track of the index.
Perhaps ...

Code:
rem as Steve said might be easier on the eyes
rem to use %@left[8,%_datetime] instead of %_date
set today=%_date
rem how many for today already? increment count
set count=%@inc[%@files[c:\%today-*.txt]]
rem make a new copy
set newfile=c:\%today-%count.txt
copy c:\form.txt %newfile
attrib -r %newfile

|And the are for?

Is there something missing from that sentence? [The forum sometimes eats text.]
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
I'm a little confused myself. Do
you want to take periodic "snapshots" of the read-only file?
Or is the read-only file truly a template that you use to create
new files from?

setlocal
set i=0
set newfile=%_date0.txt
do while EXIST %newfile
set
i=%@inc[%i]
set
newfile=%_date%%i.txt
enddo
copy template.txt %newfile
attrib -r %newfile
echo Created %newfile from template.txt
notepad %newfile
endlocal

-Scott


vefatica <> wrote on 06/13/2011
11:09:25 AM:


> From: vefatica <>
> To: Samintz@ra.rockwell.com
> Date: 06/13/2011 11:09 AM
> Subject: RE: [Support-t-2938] Dating a template
file

>
> On Mon, 13 Jun 2011 03:27:40 -0400, CWBillow <> wrote:
>
> |Code:
> |---------
> |rem could start at 0
> |set i=1
> |do file in C:\form.txt
> | copy %file C:\%_date%i.txt
> |rem then U take off the read/only
> |attrib -r c:\form.txt
> | set i=%@inc[%i]
> |enddo
> |---------
> |yes?
>
> Don't you want to remove read_only from the **new** one?
>
> If there's only one such file you don't need to loop (DO) through


> files. But if
> you're going to want several copies of it per day, and run the batchfile
each

> time you want a new one, then you'll need a way to keep track of the
index.

> Perhaps ...


> Code:
> rem as Steve said might be easier on the eyes
> rem to use %@left[8,%_datetime] instead of %_date
> set today=%_date
> rem how many for today already? increment count
> set count=%@inc[%@files[c:\%today-*.txt]]
> rem make a new copy
> set newfile=c:\%today-%count.txt
> copy c:\form.txt %newfile
> attrib -r %newfile
> |And the are for?
>
> Is there something missing from that sentence? [The forum sometimes


> eats text.]
>
>
 
Jul 12, 2008
286
0
Las Vegas, NV
Thanks Steve!

Chuck

Chuck:

I regularly use the technique of creating objects named with the current
date, with sequence numbers. For purposes of sortability I use the ISO-style
date (yyyymmdd), and number items starting with 000. Below is code you could
use (not tested, but barely changed from one I use for every new TCMD
build):


@echo off
setlocal
set d=%@left[8,%_datetime]
do n = 1000 to 1999
set dr=%[d]%@right[3,%n].txt
iff isfile %dr then
iterate
else
copy C:\form.txt %dr
attrib -r %dr
leave
endiff
enddo

A simpler method is to just just %_datetime.txt as your target name. This
guarantees unqiueness UNLESS you try to generate more than one target within
the same second. That's what I do to name my digital pictures - my camera
cannot take shoot faster.
--
Steve
 
Jul 12, 2008
286
0
Las Vegas, NV
Scott, thanks much!

Chuck


I'm a little confused myself. Do
you want to take periodic "snapshots" of the read-only file?
Or is the read-only file truly a template that you use to create
new files from?

setlocal
set i=0
set newfile=%_date0.txt
do while EXIST %newfile
set
i=%@inc[%i]
set
newfile=%_date%%i.txt
enddo
copy template.txt %newfile
attrib -r %newfile
echo Created %newfile from template.txt
notepad %newfile
endlocal

-Scott


vefatica <> wrote on 06/13/2011
11:09:25 AM:



file





each


index.
 
Jul 12, 2008
286
0
Las Vegas, NV
OKAY...

Then if this [below this paragraph] is my btm file (which works great -- thanks!), when I execute it, the TCMD window remains open until I exit the template copy.

That's OK...But is there a way to have the TCMD window closed once the template copy is opened for editing? 'Cause the "exit" at the end doesn't do it. I tried it in a couple places with no better luck.

Chuck





-----
On Mon, 13 Jun 2011 03:27:40 -0400, CWBillow <> wrote:

|Code:
|---------
|rem could start at 0
|set i=1
|do file in C:\form.txt
| copy %file C:\%_date%i.txt
|rem then U take off the read/only
|attrib -r c:\form.txt
| set i=%@inc[%i]
|enddo
|---------
|yes?

Don't you want to remove read_only from the **new** one?

If there's only one such file you don't need to loop (DO) through files. But if
you're going to want several copies of it per day, and run the batch file each
time you want a new one, then you'll need a way to keep track of the index.
Perhaps ...

Code:
rem as Steve said might be easier on the eyes
rem to use %@left[8,%_datetime] instead of %_date
set today=%_date
rem how many for today already? increment count
set count=%@inc[%@files[c:\%today-*.txt]]
rem make a new copy
set newfile=c:\%today-%count.txt
copy c:\form.txt %newfile
attrib -r %newfile

|And the are for?

Is there something missing from that sentence? [The forum sometimes eats text.]
 
May 20, 2008
3,515
4
Elkridge, MD, USA
From: CWBillow
| That's OK...But is there a way to have the TCMD window closed once
| the template copy is opened for editing? 'Cause the "exit" at the end
| doesn't do it. I tried it in a couple places with no better luck.

First, I don't recall your environment. Recently we had misunderstandings between the nature of TCMD V8 and earlier (a command processor with GUI) vs. V9 and later (a tabbed host for multiple console programs). In any case, if the editor is opened with the "start /nowait" command, the "exit" command issued any time thereafter should immediately terminate the command processor, 4NT, TCMD or TCC. However, if it was running in a tab of TCMD V9+, TCMD itself will exit only if the command processor was in the only open tab, AND the "advanced option" of TCMD "Close if no tabs exist" is enabled.
--
HTH, Steve
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
Chuck,

You can START notepad instead of running
it directly. That will prevent TCC from waiting for NOTEPAD to finish
before continuing the script.
As Steve pointed out, you should use
_DATETIME to name of your file(s) uniquely within a 1 second window. The
issue with _DATE is the "/" chars in the output.

Code:
setlocal
set newfile=%_datetime.txt
do while EXIST %newfile
        set newfile=%_datetime.txt
enddo
copy template.txt %newfile
attrib -r %newfile
echo Created %newfile from template.txt
start notepad %newfile
endlocal

-Scott

CWBillow <> wrote on 06/13/2011
02:38:48 PM:


> OKAY...
>
> Then if this [below this paragraph] is my btm file (which works
> great -- thanks!), when I execute it, the TCMD window remains open


> until I exit the template copy.
>
> That's OK...But is there a way to have the TCMD window closed once


> the template copy is opened for editing? 'Cause the "exit"
at the

> end doesn't do it. I tried it in a couple places with no better luck.
>
> Chuck
>
>
>
>
>
> -----
> Quote:
>
> Originally Posted by vefatica [image removed]
> On Mon, 13 Jun 2011 03:27:40 -0400, CWBillow
<> wrote:

>
> |Code:
> |---------
> |rem could start at 0
> |set i=1
> |do file in C:\form.txt
> | copy %file C:\%_date%i.txt
> |rem then U take off the read/only
> |attrib -r c:\form.txt
> | set i=%@inc[%i]
> |enddo
> |---------
> |yes?
>
> Don't you want to remove read_only from the **new** one?
>
> If there's only one such file you don't need to loop (DO) through


> files. But if
> you're going to want several copies of it per day, and run the batchfile
each

> time you want a new one, then you'll need a way to keep track of the
index.

> Perhaps ...


> Code:
> rem as Steve said might be easier on the eyes
> rem to use %@left[8,%_datetime] instead of %_date
> set today=%_date
> rem how many for today already? increment count
> set count=%@inc[%@files[c:\%today-*.txt]]
> rem make a new copy
> set newfile=c:\%today-%count.txt
> copy c:\form.txt %newfile
> attrib -r %newfile
> |And the are for?
>
> Is there something missing from that sentence? [The forum sometimes


> eats text.]
>
>
>
 
Jan 19, 2011
604
14
Norman, OK
Then if this [below this paragraph] is my btm file (which works great -- thanks!), when I execute it, the TCMD window remains open until I exit the template copy.

That's OK...But is there a way to have the TCMD window closed once the template copy is opened for editing? 'Cause the "exit" at the end doesn't do it. I tried it in a couple places with no better luck.

Chuck
Am I the only one not seeing his BTM file listing?

I do see the code that Scott posted in reply.

You can START notepad instead of running
it directly. That will prevent TCC from waiting for NOTEPAD to finish
before continuing the script.
As Steve pointed out, you should use
_DATETIME to name of your file(s) uniquely within a 1 second window. The
issue with _DATE is the "/" chars in the output.

Code:
setlocal
set newfile=%_datetime.txt
do while EXIST %newfile
        set newfile=%_datetime.txt
enddo
copy template.txt %newfile
attrib -r %newfile
echo Created %newfile from template.txt
start notepad %newfile
endlocal
 
Jul 12, 2008
286
0
Las Vegas, NV
Steve et al;

To clarify:

It's not notepad. but Windows Live Writer that the "wpost" is associated with and therefore is called for the editing;

I checked the TCMD Options, and it is set to "Close if no tabs...", but the default "I have" for BTM< files is TCC. Should I just set it to run from TCMD?

I tried setting up the shortcut as

C:\JPSoft\TCMD\tcmd.exe "C:\Users\CWBillow\Documents\My Weblog Posts\Drafts\BlogSetup.btm"

but then TCMD just starts up and stops -- it doesn't execute the parameter of the file.

Chuck

From: CWBillow
| That's OK...But is there a way to have the TCMD window closed once
| the template copy is opened for editing? 'Cause the "exit" at the end
| doesn't do it. I tried it in a couple places with no better luck.

First, I don't recall your environment. Recently we had misunderstandings between the nature of TCMD V8 and earlier (a command processor with GUI) vs. V9 and later (a tabbed host for multiple console programs). In any case, if the editor is opened with the "start /nowait" command, the "exit" command issued any time thereafter should immediately terminate the command processor, 4NT, TCMD or TCC. However, if it was running in a tab of TCMD V9+, TCMD itself will exit only if the command processor was in the only open tab, AND the "advanced option" of TCMD "Close if no tabs exist" is enabled.
--
HTH, Steve
 
Jul 12, 2008
286
0
Las Vegas, NV
Oh, and Steve, I/m sorry, it's Windows 7 32-bit that I'm running.

Chuck

From: CWBillow
| That's OK...But is there a way to have the TCMD window closed once
| the template copy is opened for editing? 'Cause the "exit" at the end
| doesn't do it. I tried it in a couple places with no better luck.

First, I don't recall your environment. Recently we had misunderstandings between the nature of TCMD V8 and earlier (a command processor with GUI) vs. V9 and later (a tabbed host for multiple console programs). In any case, if the editor is opened with the "start /nowait" command, the "exit" command issued any time thereafter should immediately terminate the command processor, 4NT, TCMD or TCC. However, if it was running in a tab of TCMD V9+, TCMD itself will exit only if the command processor was in the only open tab, AND the "advanced option" of TCMD "Close if no tabs exist" is enabled.
--
HTH, Steve
 
I tried setting up the shortcut as

C:\JPSoft\TCMD\tcmd.exe "C:\Users\CWBillow\Documents\My Weblog Posts\Drafts\BlogSetup.btm"

but then TCMD just starts up and stops -- it doesn't execute the parameter of the file
I don't have v8 of TC here, but I do have a couple of machines still running v7 of both TC and 4NT and I cannot reproduce what I think you are seeing. If I set up a shortcut that simply invokes TCMD.EXE with a quoted batch file name then that batch file runs and I'm left at the TC prompt. However, in my case TCMD cannot find an INI file or a TCSTART (these are shared with 4NT and stored in a directory above that where TCMD.EXE lives) and I wonder whether or not that is playing into this in your case. Does it make any difference if you create a simple one-line BTM (with an ECHO, say) and execute that instead??

What you are trying to do should work, but you can also tweak the behaviour by supplying a /@fully_qualified_ini_filename and/or the /C or /K switches (the former forces the instance of TC to use a particular INI file and the latter either Closes or Keeps the TC instance once it has finished running the specified batch file).
 
Similar threads
Thread starter Title Forum Replies Date
F Dating a log Support 14
F Dating logs Support 17
J History file load hangs if file has complete garbage in it... Support 1
jdanielp Cannot step into and/or call another .bat file when debugging .bat file Support 2
thorntonpg file explorer - short cut keys Support 1
JohnQSmith New online help file wrong logo Support 7
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
samintz How to? swap endianness in a binary file Support 12
vefatica `Back quotes` - command line vs. batch file Support 5
fpefpe How to? batch file size Support 2
Jay Sage Issues With TCMD File Explorer Support 0
FreezerBurnt Help making a CMD and TCC compatible batch file Support 7
Joe Caverly @FILESIZE and NTFS File Stream Support 1
Joe Caverly Embedding an .EXE (or other file) into a .BTM Support 8
U Command help on file names Support 5
S Concatenate all playlists into 1 file Support 22
Joe Caverly Set a batch variable (%1 - %n) when TCC is executing a batch file Support 5
Joe Caverly Rename file that begins with Emoji Support 7
Joe Caverly PSHELL and NTFS File Streams Support 2
P Kill all other instances of tcc from a btm batch file Support 2
D ffind hangs on large file Support 18
Alpengreis Documentation Minor issue in help file for view /E Support 1
fpefpe batch file ending early Support 18
J Licesne file location Support 1
K robocopy cancelling batch file processing Support 28
Jay Sage TCMD Crashes with "tctoolbar /c /r file" Support 5
A Unable to pass batch file arguments unaltered Support 18
MikeBaas How to...extract a string from a .json-file? Support 10
vefatica LIBRARY and file name completion? Support 4
D What does the file "..\Everything\Run history.csv" store? Support 5
H Takecommand.pdf failed not a pdf file Support 6
Joe Caverly DIRectory Colorization in v25 Help File Support 0
C show file description? with dir? Support 8
D When copying/moving, appending " (2)" to filename when the target file already exist. Support 7
R How to? Dir specific file search patterns with spaces in the pathnames? Support 6
Joe Caverly _EXPANSION in help file Support 0
Stefan Hassel Installation file TC 24.02 Build 47 is actually version 25.00.1 Support 10
vefatica Are @FILEDATE[file] and @FILEDATE[file,u] ever different? Support 2
K_Meinhard Help file error Support 1
Joe Caverly JOBMONITOR in Help File Support 1
D btm file command line augments comparing for string or math. Support 12
A Documentation [Help file] OPTION "//" synopsis formatting issue Support 0
vefatica Can TCC complete this file name? Support 5
G tcedit ist not run in tc 24 file explorer Support 10
M How to set Path variable for non-executable file extensions in 4DOS Support 8
I zip /M fails to delete file after adding to zip file Support 2
Charles Dye Is the "File Associations" installer dialog working? Support 4
J File explorer handling from command line? Support 2
Joe Caverly v24 Help File - DATEMONITOR Support 1
MickeyF Why does this batch file give me 'unknown command "else"' error? Support 17

Similar threads