MISS VIP Topic Starter
Posts: 11
|
 |
« on: July 01, 2008, 02:46:45 AM » |
|
HI ,  IM WRITING a batch file this batch file should compare the date modifid of a file with the current date if the current date is less than 15 min of the file date then copy this file to another directory.. PLEASE HELP and thanks in advanced ...
|
|
|
|
|
blastman
Posts: 303
|
 |
« Reply #1 on: July 01, 2008, 02:49:49 AM » |
|
what have you got so far???
|
Blastman, you are the man. Thank You Very Much!!!!!!!!!
|
|
|
MISS VIP Topic Starter
Posts: 11
|
 |
« Reply #2 on: July 01, 2008, 02:57:36 AM » |
|
@ECHO OFF CLS
:START IF "%1" == "" S:\AISHA\MSG *.TXT /* SEARCH FOR TEXT FILE ONLY GOTO SER_DATE
SER_DATE /* COMPARE DATE MODIFIED WITH CURRENT DATE IF SYS<=15 MIN THEN GOTO COPY_FILE */
==THIS PART IS MISSING ==
GOTO COPY_FILE /* COPY FROM S:\MSG.TXT TO C:\IN */
COPY_FILE IF "%1" == "" XCOPY S:\HII\MSG.TXT IF NOT "%1" == "" XCOPY S:\%1 ECHO. C:\IN
REM Execute the MS-DOS dir command ever 60 MIN. dir SLEEP 60 GOTO START
|
|
|
|
|
Dias de verano Guest
|
 |
« Reply #3 on: July 01, 2008, 03:28:45 AM » |
|
/* COMPARE DATE MODIFIED WITH CURRENT DATE IF SYS<=15 MIN THEN GOTO COPY_FILE */
You don't do comments like this. They start with REM.
|
|
|
|
|
MISS VIP Topic Starter
Posts: 11
|
 |
« Reply #4 on: July 01, 2008, 03:42:17 AM » |
|
THANKS DIAS ANY HINT FOR MY MISSING PART ?
|
|
|
|
|
MISS VIP Topic Starter
Posts: 11
|
 |
« Reply #5 on: July 01, 2008, 03:52:52 AM » |
|
I CORRECT IT  @ECHO OFF CLS :START IF "%1" == "" S:\AISHA\MSG *.TXT /* SEARCH FOR TEXT FILE ONLY GOTO SER_DATE SER_DATE REM COMPARE DATE MODIFIED WITH CURRENT DATE IF SYS<=15 MIN THEN GOTO COPY_FILE  GOTO COPY_FILE REM COPY FROM S:\MSG.TXT TO C:\IN COPY_FILE IF "%1" == "" XCOPY S:\HII\MSG.TXT IF NOT "%1" == "" XCOPY S:\%1 ECHO. C:\IN GOTO SLP REM Execute the MS-DOS dir command ever 60 MIN. SLP SLEEP 60 GOTO START
|
|
|
|
|
MISS VIP Topic Starter
Posts: 11
|
 |
« Reply #6 on: July 01, 2008, 04:33:00 AM » |
|
I FOUND THIS CODE DIR %1 ¦ FIND /I "%1" > ~ISMODIF.TMP ECHO.>> ~ISMODIF.TMP TYPE ~ISMODIF.TMP ¦ TIME ¦ FIND /I "%1" > ~ISMODIF.BAT ECHO SET CHKDATE=%%4> ENTER.BAT CALL ~ISMODIF.BAT DIR ~ISMODIF.BAT ¦ FIND /I "~ISMODIF.BAT" > ~ISMODIF.TMP ECHO.>> ~ISMODIF.TMP TYPE ~ISMODIF.TMP ¦ TIME ¦ FIND /I "~ISMODIF.BAT" > ~ISMODIF.BAT ECHO SET NOWDATE=%%4> ENTER.BAT CALL ~ISMODIF.BAT IF "%NOWDATE%"=="%CHKDATE%" ECHO %1 was created or modified todayIS THIS CODE WILL MEET MY REQUIRMENT WHICH IS COMPARE DATE MODIFIED WITH CURRENT DATE IF SYS<=15 MIN THEN COPY_FILE TO DIFFERENT DIRECTORY
|
|
|
|
|
ghostdog74
Thanked: 26 Posts: 1,511
|
 |
« Reply #7 on: July 01, 2008, 07:22:11 AM » |
|
there are abundance of tools out there you can use. the unix Find command , which is ported to windows makes this kind of task seem trivial. Otherwise, here's a vbscript Set objFS = CreateObject("Scripting.FileSystemObject") strFolder = "C:\test" dstFolder = "c:\destination" Set objFolder = objFSO.GetFolder(strFolder) For Each strFiles In objFolder.Files If DateDiff("n",strFiles.DateLastModified,Now) > 15 Then WScript.Echo strFiles.Name objFS.MoveFile strFiles.Name, dstFolder & "\" & strFiles.Name End If Next
|
|
|
|
Dias de verano Guest
|
 |
« Reply #8 on: July 01, 2008, 09:54:56 AM » |
|
Miss VIP, is there a Caps Lock key on your keyboard?
|
|
|
|
|
MISS VIP Topic Starter
Posts: 11
|
 |
« Reply #9 on: July 01, 2008, 10:54:49 PM » |
|
Thankx "ghostdog74 "  i'll try to test ur code ... Dias de verano : NO THIER IS NO CAPS LOCK hehehehehehe
|
|
|
|
|
MISS VIP Topic Starter
Posts: 11
|
 |
« Reply #10 on: July 03, 2008, 04:17:59 AM » |
|
ghostdog74 , how can i attch your code and put it in my code ??
i could not be able to add what u wrote in my code !!
this is my code and in red is what you wrote :
@ECHO OFF CLS
:START IF "%1" == "" S:\AISHA\MSG *.TXT /* SEARCH FOR TEXT FILE ONLY GOTO SER_DATE
SER_DATE REM COMPARE DATE MODIFIED WITH CURRENT DATE IF SYS<=15 MIN THEN GOTO COPY_FILE
[color=red]Set objFS = CreateObject("Scripting.FileSystemObject") strFolder = "C:\test" dstFolder = "c:\destination" Set objFolder = objFSO.GetFolder(strFolder) For Each strFiles In objFolder.Files If DateDiff("n",strFiles.DateLastModified,Now) > 15 Then WScript.Echo strFiles.Name objFS.MoveFile strFiles.Name, dstFolder & "\" & strFiles.Name End If Next[/color]
GOTO COPY_FILE REM COPY FROM S:\MSG.TXT TO C:\IN
COPY_FILE IF "%1" == "" XCOPY S:\HII\MSG.TXT IF NOT "%1" == "" XCOPY S:\%1 ECHO. C:\IN GOTO SLP
REM Execute the MS-DOS dir command ever 60 MIN.
SLP SLEEP 60 GOTO START
thanks in advance ....
|
|
|
|
|
ghostdog74
Thanked: 26 Posts: 1,511
|
 |
« Reply #11 on: July 03, 2008, 05:47:12 AM » |
|
it is a vbscript. save the code as script.vbs and on command line just type
C:\test> cscript /nologo script.vbs
assuming your script is stored in c:\test
|
|
|
|
MISS VIP Topic Starter
Posts: 11
|
 |
« Reply #12 on: July 06, 2008, 09:48:08 PM » |
|
thankx "ghostdog74 " for ur effort -- i got some error  my batch file code is like that : @ECHO OFF CLS
:START REM SEARCH FOR TEXT FILE ONLY
IF "%1" == "" S:\AISHA\MSG *.TXT GOTO SER_DATE
SER_DATE REM COMPARE DATE MODIFIED WITH CURRENT DATE IF SYS<=15 MIN THEN GOTO COPY_FILE
REM it will go to the vbs file
C:\IN> cscript /nologo script.vbs
REM Execute the MS-DOS dir command ever 60 MIN.
SLP SLEEP 60 GOTO START and my vbs file is like that :Set objFS = CreateObject("Scripting.FileSystemObject") strFolder = " S:\AISHA\MSG *.TXT" dstFolder = "C:\IN" Set objFolder = objFSO.GetFolder(strFolder) For Each strFiles In objFolder.Files If DateDiff("n",strFiles.DateLastModified,Now) > 15 Then WScript.Echo strFiles.Name objFS.MoveFile j:\msg.txt, dstFolder & "\" & strFiles.Name End If Next goto copy_file
where is the error
|
|
|
|
|
ghostdog74
Thanked: 26 Posts: 1,511
|
 |
« Reply #13 on: July 07, 2008, 05:36:12 AM » |
|
i don't know , you tell me.
|
|
|
|
macdad-
Thanked: 39 Posts: 2,520
|
 |
« Reply #14 on: July 07, 2008, 06:23:21 AM » |
|
ok you need to learn how to program in batch code, we're not your servants, we can help u but you have to think on your own. where is the error
open up VB express and debug it, it will tell you the errors and on wat line they are. and look at the attachment noticed how i used all lower case without caps. [recovering disk space -- attachment deleted by admin]
|
If you dont know DOS, you dont know Windows... Thats why Bill Gates created the Windows NT Family. 
|
|
|
MISS VIP Topic Starter
Posts: 11
|
 |
« Reply #15 on: July 13, 2008, 03:48:21 AM » |
|
thankx "ghostdog74" i'll fine out the error and i'll tell you
|
|
|
|
|
Dias de verano Guest
|
 |
« Reply #16 on: July 13, 2008, 01:52:43 PM » |
|
IF "%1" == "" S:\AISHA\MSG *.TXT GOTO SER_DATE This line is nonsense.
Also, if SER_DATE is a label, it should start with a colon.
C:\IN> cscript /nologo script.vbs Why is C:\IN> at the beginning? This will not work.
REM Execute the MS-DOS dir command ever 60 MIN.
SLP SLEEP 60 GOTO START What is SLP? A label? a program? Why is it there?
Execute the dir command? Where? How?
|
|
|
|
|
MISS VIP Topic Starter
Posts: 11
|
 |
« Reply #17 on: July 13, 2008, 09:47:21 PM » |
|
hi Dias de verano ,
the first code
IF "%1" == "" S:\AISHA\MSG *.TXT GOTO SER_DATEit will go to aisha file in S drive and search only for text files. then it will go to ser_date command.
C:\IN> cscript /nologo script.vbs C:\IN is the name of the folder where i kept my script.vbs
REM Execute the MS-DOS dir command ever 60 MIN.
SLP SLEEP 60 GOTO START
SLP is the name of the command if the previous code execute perfectly then it will go to SLP to sleep for 60 min then it eill go to start to start again..
am i doing somthing wrong ?
thankx for ur helps guys..
|
|
|
|
|
MISS VIP Topic Starter
Posts: 11
|
 |
« Reply #18 on: July 20, 2008, 04:16:10 AM » |
|
N=Now Set objFSO = CreateObject("Scripting.FileSystemObject") strFolder=" S:\out" strNewDest = "C:\IN" Set objFolder = objFSO.GetFolder(strFolder) For Each strFiles In objFolder.Files If DateDiff("d",N, strFiles.DateLastModified) >1 Then 'objFSO.MoveFile strFiles , strNewDest & "\" & strFiles.Name Wscript.Echo strFiles.Name End If Next
i tried this VBS code .. it gave an error in the fifth line and the error is (path not found )?!
the one is calculated as one day how can i convert it to min. ?
thanks in advance
|
|
|
|
|
Dias de verano Guest
|
 |
« Reply #19 on: July 20, 2008, 04:47:17 AM » |
|
strFolder=" S:\out" Try removing the space before the S:\out
|
|
|
|
« Last Edit: July 20, 2008, 06:47:34 AM by Dias de verano »
|
IP logged
|
|
|
|
Sidewinder
Thanked: 97 Posts: 4,342
Experience: Familiar OS: Windows 7
|
 |
« Reply #20 on: July 20, 2008, 06:44:12 AM » |
|
the one is calculated as one day how can i convert it to min. ?
Do the arithmetic in minutes: If DateDiff("n", strFiles.DateLastModified, Now) > 15 Then
I think this was the original code. Something may have gotten lost in the translation. 
|
If you don't know where you are going, any road will get you there
-Lewis Carroll
|
|
|
ALAN_BR
Thanked: 5 Posts: 346
|
 |
« Reply #21 on: September 01, 2008, 09:41:08 AM » |
|
There seems to be a fundamental flaw from the very first post.
From the ambitions / intentions expressed in the comments it appears that :- a) Any recent file that is less than 15 minutes of age is to be archived; b) The above rule will exclude from archiving any thing created / altered in the next 45 minutes, unless the SLEEP period is reduced from 60 minutes down to 15.
Regards Alan
|
Acer Laptop TravelMate 244LM. 1.25 GB Ram + 160 GB HDD. C:\ = 20 GB. Windows XP Home Edition with SP3; Acronis T.I. 11.0 (build*8,101); Protection ESET NOD32 v 2.7 Antivirus plus Comodo Firewall 3.5. PerfectDisk 2008 v 9.0.0.64; Partition Wizard EasyBcd Dual Boot, Default XP, W7 if I really have to
|
|
|