<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Batch file commands' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Batch file commands' posted on the 'MS-DOS' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2012 Programmers Heaven</copyright>
    <pubDate>Thu, 09 Feb 2012 08:19:50 -0800</pubDate>
    <lastBuildDate>Thu, 09 Feb 2012 08:19:50 -0800</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Batch file commands</title>
      <link>http://www.programmersheaven.com/mb/MS-DOS/410778/410778/batch-file-commands/</link>
      <description>Hi, &lt;br /&gt;
I am very new when it comes to batch files and I need to copy some files from a directory to another on a windows 2003 server.&lt;br /&gt;
I have writeen a simple batch file which looks like this:&lt;br /&gt;
&lt;br /&gt;
@echo off&lt;br /&gt;
SET Day=%date:~0,2%&lt;br /&gt;
SET Month=%date:~3,2%&lt;br /&gt;
SET Year=%date:~6,4%&lt;br /&gt;
SET cdate=%Year%%Month%%Day%&lt;br /&gt;
 &lt;br /&gt;
SET localDir=D:\New_Files&lt;br /&gt;
SET newDir=D:\test&lt;br /&gt;
&lt;br /&gt;
COPY "D:\New_Files\*.dat" "D:\test\*.dat" &lt;br /&gt;
&lt;br /&gt;
pause&lt;br /&gt;
rem dir c:\windows&lt;br /&gt;
&lt;br /&gt;
This is all work, bt the problem I am having is that I only need to copy across files whose date is in the past, i.e.:&lt;br /&gt;
The list of files is this&lt;br /&gt;
a20091211.dat&lt;br /&gt;
a20091212.dat&lt;br /&gt;
b20091216.dat&lt;br /&gt;
c20091214.dat&lt;br /&gt;
c20091215.dat&lt;br /&gt;
e20091101.dat&lt;br /&gt;
&lt;br /&gt;
Today is the 15th December 2009 and the file for today would like *20091215.dat. I need to copy all and only the files whose date is prior to today, so I should just move the below files:&lt;br /&gt;
&lt;br /&gt;
a20091211.dat&lt;br /&gt;
a20091212.dat&lt;br /&gt;
c20091214.dat&lt;br /&gt;
e20091101.dat&lt;br /&gt;
&lt;br /&gt;
I have searched high and low on the web and could not find anything: can you please advise on a solution or anywhere where I can find a way to do it?&lt;br /&gt;
Thanks &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/MS-DOS/410778/410778/batch-file-commands/</guid>
      <pubDate>Tue, 15 Dec 2009 08:49:37 -0800</pubDate>
      <category>MS-DOS</category>
    </item>
    <item>
      <title>Re: Batch file commands</title>
      <link>http://www.programmersheaven.com/mb/MS-DOS/410778/410858/re-batch-file-commands/#410858</link>
      <description>I think you may need something in addition to DOS.&lt;br /&gt;
&lt;br /&gt;
There are two ways to do this. One way is based on the file names, the other is based on file creation time.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;METHOD 1 - File Name&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class="sourcecode"&gt;# Script CopyButToday.txt
var str today, filelist, file
# Get today's date
set $today = gettime()
chex "8]" $today &amp;gt; $today
# Collect a list of all *.dat files in D:\New_Files.
lf -n "*.dat" "D:\New_Files" &amp;gt; $filelist
while ($filelist &amp;lt;&amp;gt; "")
do
    lex "1" $filelist &amp;gt; $file
    # Does this file have $today in its name ?
    if ( { sen ("^"+$today+"^") $file } &amp;lt;= 0 )
        # No file does not have $today in the name.
        # Copy this file.
        system copy ("\""+$file+"\"") "D:\test"
    endif
done&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;METHOD 2 - File Creation Time&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class="sourcecode"&gt;# Script CopyButToday.txt
var str today, filelist, file
# Get today's date
set $today = gettime()
chex "8]" $today &amp;gt; $today
# Collect a list of all *.dat files in D:\New_Files
# that have been created before $today
lf -n "*.dat" "D:\New_Files" ($fctime &amp;lt; $today) &amp;gt; $filelist
while ($filelist &amp;lt;&amp;gt; "")
do
    lex "1" $filelist &amp;gt; $file
    # Copy this file.
    system copy ("\""+$file+"\"") "D:\test"
done&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Both scripts are in biterscripting ( &lt;a href="http://www.biterscripting.com"&gt;http://www.biterscripting.com&lt;/a&gt; ). Whichever method you choose, save the script in file C:/Scripts/CopyButToday.txt, start biterscripting, and enter the following command.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;script "C:/Scripts/CopyButToday.txt"&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
That would do it.&lt;br /&gt;
&lt;br /&gt;
If you make the scripts even fancier, please post them for others.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/MS-DOS/410778/410858/re-batch-file-commands/#410858</guid>
      <pubDate>Thu, 17 Dec 2009 09:53:41 -0800</pubDate>
      <category>MS-DOS</category>
    </item>
    <item>
      <title>Re: Batch file commands</title>
      <link>http://www.programmersheaven.com/mb/MS-DOS/410778/412163/re-batch-file-commands/#412163</link>
      <description>Good ,thanks a lot.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/MS-DOS/410778/412163/re-batch-file-commands/#412163</guid>
      <pubDate>Thu, 21 Jan 2010 12:56:02 -0800</pubDate>
      <category>MS-DOS</category>
    </item>
  </channel>
</rss>
