|
|
|
Copying files-date as a parameter
|
Original Message
|
Name: ugandhar
Date: March 23, 2003 at 08:58:46 Pacific
Subject: Copying files-date as a parameter OS: DOS CPU/Ram: 256MB
|
Comment: Hi, We have windows 98 network. My problem is I have to copy a Microsoff access file name as abc.mdb to another location every day. But I need to keep the old one too in the new location. So, I'm trying to send "date" command as a parameter and trying to add date to the same file abc.mdb as abc.mdb_032303. Can any one give me the code for this please. I want to run this as a bacth job every day on scheduler. Please help me.....
Report Offensive Message For Removal
|
|
Response Number 2
|
Name: ugandhar
Date: March 24, 2003 at 20:19:49 Pacific
|
Reply: (edit)Hi, I tried with the below script (got from ur web page): :: Get current date into %date% variable @echo off echo @PROMPT SET DATE=$D$_> %TEMP%.\T1.BAT %COMSPEC% /C %TEMP%.\T1.BAT > %TEMP%.\T2.BAT call %TEMP%.\T2.BAT for %%? in (1 2) do del %TEMP%.\T%%?.BAT echo DATE=%DATE% Output: I'm getting error as "Out of Environemt space" Bad command or file name DATE= Question: It seems Date variable is not passing. I'm using Windows'98 [Version 4.10.1998] Even I tried the command date/T also. I'm getting an error saying "Invalid date" and asking to enter a new date. So, it seems the commands which works on Windows 2000/NT won't work in windows 98. HELP NEEDED. PLEASE HELP ME.
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: IVO
Date: March 25, 2003 at 06:39:47 Pacific
|
Reply: (edit)If you are operating under Windows 9x/ME, forget Date /T and similar commands: they are specific of the NT kernel based operating systems i.e. Windows NT/2K/XP. The DOS box under NT systems is an emulated DOS window *not* a true DOS prompt. So stated, undere Windows 9X You must enlarge your environment space. There many ways to accomplish this, here a radical one: insert this line at the end of your config.sys in the root directory Shell=C:\Windows\Command\Command.com /E:4096 /P This will set your environment space to 4096 bytes solving your trouble. The path of command.com may differ in your system. I hope this helps.
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: Secret_Doom
Date: March 25, 2003 at 11:54:18 Pacific
|
Reply: (edit)Ugandhar, you can make the batch script itself enlarge the environment space: @echo off if "%1"=="GoTo" goto %2 %comspec% /e:4096 /c %0 GoTo start goto eof :start echo.EXIT|%COMSPEC%/K PROMPT SET %%1=$D$_|FIND " "> %TEMP%.\T1.BAT type nul> %TEMP%.\T2.DAT for %%? in (e10D''3B e110''3B w q) do echo %%?>> %TEMP%.\T2.DAT DEBUG %TEMP%.\T1.BAT < %TEMP%.\T2.DAT > nul call %TEMP%.\T1.BAT DATE echo SET DATE=%%2%%3%%4> %TEMP%.\T1.BAT call %TEMP%.\T1.BAT %DATE% for %%? in (T1.BAT T2.DAT) do del %TEMP%.\%%? echo DATE=%DATE% :eof In that script, I've used the subroutine concept. The 2nd line is somekind of subroutine handler. The 3rd line calls the script from itself, but in a child shell with expanded environment space. However, on this second call, the subroutine handler will make the process go straigt to the :
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: Secret_Doom
Date: March 25, 2003 at 11:54:21 Pacific
|
Reply: (edit)Ugandhar, you can make the batch script itself enlarge the environment space: @echo off if "%1"=="GoTo" goto %2 %comspec% /e:4096 /c %0 GoTo start goto eof :start echo.EXIT|%COMSPEC%/K PROMPT SET %%1=$D$_|FIND " "> %TEMP%.\T1.BAT type nul> %TEMP%.\T2.DAT for %%? in (e10D''3B e110''3B w q) do echo %%?>> %TEMP%.\T2.DAT DEBUG %TEMP%.\T1.BAT < %TEMP%.\T2.DAT > nul call %TEMP%.\T1.BAT DATE echo SET DATE=%%2%%3%%4> %TEMP%.\T1.BAT call %TEMP%.\T1.BAT %DATE% for %%? in (T1.BAT T2.DAT) do del %TEMP%.\%%? echo DATE=%DATE% :eof In that script, I've used the subroutine concept. The 2nd line is somekind of subroutine handler. The 3rd line calls the script from itself, but in a child shell with expanded environment space. However, on this second call, the subroutine handler will make the process go straigt to the :start process. Then, when the process on the child process is over, we return to the 4th line (back to the parental shell), which exits. You should mantain the first and second lines from the script when modifying it. Oh, and the changes on the environment (variables) made on the child shell don't affect the environment from the parental shell (it means you gotta use the %date% variable right after it is set, on the :start label. it will have no value on the parent shell, after the 3rd line) BTW, in your case you gotta use the script that gets out the date separators, not that one you posted. -- Leonardo Pignataro - Secret_Doom -- secret_doom@hotmail.com www.batch.hpg.com.br ____________________________________________________________________
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: Secret_Doom
Date: March 25, 2003 at 11:56:00 Pacific
|
Reply: (edit)Hey, that response #4 wasn't supposed to get posted, it was an internal error from the site, I guess. -- Leonardo Pignataro - Secret_Doom -- secret_doom@hotmail.com www.batch.hpg.com.br
Report Offensive Follow Up For Removal
|
|
Response Number 7
|
Name: ugandhar
Date: March 25, 2003 at 19:49:43 Pacific
|
Reply: (edit)Thank you for the information. It worked. Its really great help. I'm thankful once again. By the way, I guess this is simple question probably. I'm using 'COPY' command as mentioned below after executing ur script: COPY c:\folder1\file.txt c:\folder2\file%DATE%.txt /Y In the folder2 I'm getting 2 files with the name file.txt and file032520003.txt files. Is there any way can I get only one file name as file032520003.txt Please help me.
Report Offensive Follow Up For Removal
|
|
Response Number 8
|
Name: Secret_Doom
Date: March 26, 2003 at 09:07:49 Pacific
|
Reply: (edit)Well, that command you mentioned will make a single copy of the source file (c:\folder1\file.txt) on the destination. If you're getting two files, it's because the file is being copied somewhere else... Try looking at the source, you might've forgotten a line like this somewhere; copy c:\folder1\file.txt c:\folder2 Anyway, you can always delete the unwanted file... del c:\folder2\file.txt -- Leonardo Pignataro - Secret_Doom -- secret_doom@hotmail.com www.batch.hpg.com.br
Report Offensive Follow Up For Removal
|
Use following form to reply to current message:
|
|

|