There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
blue screen boot computer connection cpu crash css dell display driver drivers email error ethernet excel firefox firefox 3 game hard drive hardware internet internet explorer itunes laptop malware monitor network networking nvidia outlook outlook 2003 outlook express partition printer problem problems router security slow software sound sprtcmd.exe trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Batch Files


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
da1i1princess's Avatar
Junior Member with 3 posts.
 
Join Date: Nov 2007
Experience: Beginner
08-Nov-2007, 10:23 AM #1
Batch Files
I know it's archaic.

Here's my dilemma...I've got an archive folder that has files dating back from 2006. I want to create a batch file to copy the most recently dated files to another folder called Daily. This would run each day.

Is it possible to denote that???

Here is an example of my script:

copy "c:\TEST\site\archives\*.*" %GOTO CUR-DATE% "C:\TEST\site\Daily" /y

I've tried to run it several times and it just copies "all" the files in the archive folder over.

Thanks to whomever can help me.
johnhe's Avatar
Member with 56 posts.
 
Join Date: May 2007
Experience: Advanced
08-Nov-2007, 12:14 PM #2
If this is a Windows system you can use XCOPY to do this by using the /D:m-d-y to specify copying only those files modified or created on or after the specified date. For example to copy only those files created or changed today you could specify:

xcopy "c:\TEST\site\archives\*.*" "C:\TEST\site\Daily" /d:11-08-2007

John Hensley
www.resqware.com
da1i1princess's Avatar
Junior Member with 3 posts.
 
Join Date: Nov 2007
Experience: Beginner
13-Nov-2007, 07:11 AM #3
Thanks John for replying. Yes, it is a Windows system. I have tried your suggestion and that does work...but I'm lookin for a script that would automatically pull the current file vs. me actually having to put in a date. I have to pull files daily and this would make life a whole lot simpler.

Do you know a way that I can accomplish this?
da1i1princess's Avatar
Junior Member with 3 posts.
 
Join Date: Nov 2007
Experience: Beginner
13-Nov-2007, 02:00 PM #4
I've been googlin my topic and I think this might work...I just don't know how to rewrite it to fit what I need.

:: CTULD.bat
:: Copies Files Modified or Created Today
:: to the Upload Directory, or Copies
:: from the Specified Date Forward
::
@ECHO OFF
If no Date is Given, Today's
IF "%1" == "" GOTO COPY-TODAY Files will be Copied
IF NOT "%1" == "" GOTO COPY-DATE Otherwise, Files will be Copied
Forward of the Date Typed

:COPY-TODAY (See Text, Below)
ECHO. | DATE | FIND /I "Current" > C:\BATCH\CUR-DATE.BAT
ECHO @SET CUR-DATE=%%4 > C:\BATCH\CURRENT.BAT
CALL C:\BATCH\CUR-DATE.BAT

XCOPY *.* C:\UPLOAD /D:%CUR-DATE% < NUL Copies Files based on
Today's Date
("NUL" Hides Screen Messages)
GOTO END

:COPY-DATE Copies Files based on
XCOPY *.* C:\UPLOAD /D:%1 /-Y The Date Given at the
Command Line
:END
ECHO. Separates the Listing
CALL C:\BATCH\DR.BAT C:\UPLOAD Gives a Listing for the
UPLOAD Directory to
Show the Operation's Success

SET CUR-DATE= Removes the Date Variable
From the Environment

DEL CUR-DATE.BAT Deletes the
DEL CURRENT.BAT Temporary Batch Files
johnhe's Avatar
Member with 56 posts.
 
Join Date: May 2007
Experience: Advanced
13-Nov-2007, 10:33 PM #5
If you are using Windows 2K or later this should work.

@ECHO OFF
REM Create TODAY environment variable in the format mm-dd-yyyy
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET TMPDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %TMPDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %TMPDATE%') DO SET yyyy=%%B
SET TODAY=%mm%-%dd%-%yyyy%
REM Copy the files with today's date
xcopy "c:\TEST\site\archives\*.*" "C:\TEST\site\Daily" /d:%TODAY% /y
REM Delete evironment variables
SET TMPDATE=
SET dd=
SET mm=
SET yyyy=
SET TODAY=
__________________
John Hensley
www.resqware.com

Last edited by johnhe : 14-Nov-2007 02:38 PM.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:58 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.