1.

Solve : Second part of my batch file?

Answer»

Good-DAY,

I've got my first piece of code which will save the text information using >> to the C DRIVE.

Now I need some help with ANOTHER batch FILE to take that txt file information and save a copy everyday with another text name.

Thanks for any help


Here is a link to your previous post.

You could do a simple Copy and append the date (or the date and time) to the filename so that you could finish with the input being filename.log and output filename26Nov2007.log

Post some coding when you're ready.









The AutoEXE batch file on the C drive makes programs run on start up if they are inputed in the code. I suggest you use the copy function in there and copy your file to the date and time.

The only problem is that the following will run on your computers start up whether it is on the same day or not.

Example:(PUT code somewhere in the AutoEXE batch file

Below for the Date:(all on one line)

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "(ENTER FILE NAME HERE).txt" %%e-%%f-%%g.txt

Below for the Time:(again all on one line)

for /f "tokens=1-5 delims=:" %%d in ("%time%") do rename "(ENTER FILE NAME HERE).txt" %%d-%%e.txt

Where in the code it says (ENTER FILE NAME HERE) put the file you want to copy here.
also the .txt does not have to be .txt it can be .exe or .bat its up to you.

The program below is the one I wrote for a similar problem.

@echo off
title Change
:start
echo >rename.txt
echo would you like to change the name of rename.txt to the current date/time?
set/p "cho=>"
if %cho%==Yes goto yes
if %cho%==yes goto yes
if %cho%==No goto no
if %cho%==no goto no
ping localhost -n 2 >nul
echo must be a yes or no answer!!
ping localhost -n 2 >nul
cls
goto start

:yes
cls
echo would you like to change date or time?
set/p "cho=>"
if %cho%==date goto one
if %cho%==time goto two
ping localhost -n 2 >nul
echo must be either 1 or 2(one or two)
ping localhost -n 2 >nul
cls
goto yes

:one
cls
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "Backup.cv" %%e-%%f-%%g.cvm
pause >nul
goto end

:two
cls
for /f "tokens=1-5 delims=:" %%d in ("%time%") do rename "Backup.cv" %%d-%%e.cvm
pause >nul
goto end

:no
cls
echo if you didn't want to change the date and time of that text file
echo then what did you want to do?
pause >nul
goto end

:end

Thats all I hope that all of this helped



Discussion

No Comment Found