1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Dating a template file

Discussion in 'Support' started by CWBillow, Jun 13, 2011.

  1. CWBillow

    Joined:
    Jul 12, 2008
    Messages:
    194
    Likes Received:
    0
    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
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,777
    Likes Received:
    29
    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
     
  3. CWBillow

    Joined:
    Jul 12, 2008
    Messages:
    194
    Likes Received:
    0
    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




     
  4. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    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
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,777
    Likes Received:
    29
    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.]
     
  6. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,177
    Likes Received:
    11
    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.



     
  7. CWBillow

    Joined:
    Jul 12, 2008
    Messages:
    194
    Likes Received:
    0
    Thanks Steve!

    Chuck

     
  8. CWBillow

    Joined:
    Jul 12, 2008
    Messages:
    194
    Likes Received:
    0
    Scott, thanks much!

    Chuck


     
  9. CWBillow

    Joined:
    Jul 12, 2008
    Messages:
    194
    Likes Received:
    0
    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





    -----
     
  10. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    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
     
  11. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,177
    Likes Received:
    11
    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:




    at the

    <> wrote:


    each

    index.



     
  12. JohnQSmith

    Joined:
    Jan 19, 2011
    Messages:
    560
    Likes Received:
    8
    Am I the only one not seeing his BTM file listing?

    I do see the code that Scott posted in reply.

     
  13. CWBillow

    Joined:
    Jul 12, 2008
    Messages:
    194
    Likes Received:
    0
    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

     
  14. CWBillow

    Joined:
    Jul 12, 2008
    Messages:
    194
    Likes Received:
    0
    Oh, and Steve, I/m sorry, it's Windows 7 32-bit that I'm running.

    Chuck

     
  15. Steve Pitts

    Joined:
    Jul 7, 2008
    Messages:
    158
    Likes Received:
    0
    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).
     

Share This Page