Batch File Rename + Date added & Move to another location

C

carla_cund

Hi

I hope someone can help. I have searched around all the posts but to
be honest i cant quite find what im lookng for exactly.

I need to run a batch file which will go to this location
c:\perflogs\networksops2.csv and move this file to a level down
c:\perflogs\archivedperflogs and rename the file keeping the original
name but adding a date to it ie networkops220070117.csv

This needs to be run every week on a schedule. The original location
every week will have the c:\perflogs\networksops2.csv file added by a
performance log. I need to then archive this data off so it is not
overwritten every week

Can anyone please help, I am new to batch file writing. This is what i
have so far. Not much i know

move c:\perflogs\networksops2.csv
c:\perflogs\archivedperflogs\networksops2.csv

hope someone can help me

thanks alot

Carla
 
F

foxidrive

I need to run a batch file which will go to this location
c:\perflogs\networksops2.csv and move this file to a level down
c:\perflogs\archivedperflogs and rename the file keeping the original
name but adding a date to it ie networkops220070117.csv

This needs to be run every week on a schedule. The original location
every week will have the c:\perflogs\networksops2.csv file added by a
performance log. I need to then archive this data off so it is not
overwritten every week

Try this: (untested)

@echo off
:: Code by Herbert Kleebauer
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>d_t.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>d_t.com
echo LisqMz`wGH@wKuur`G@w?ogBgGG}G?j_egoNOG?w?`gBLksqgG`w?WgBgG>>d_t.com
echo G}G?R_MgoNMy?wSx@W?s?W?@zAB`LrFuBLyt~vuco{@LuKooD?BFHqrIcP>>d_t.com
echo _sdDxb1T??=?rILO_sdDqx1T??=?rILO_sdDnl1T??=?rILO_sdD`c1T??>>d_t.com
echo =?rILO_sdDgg1T??=?rILO_sdDll1T??=?rILO_sdDrr1T??=??IL?0xxx>>d_t.com

d_t.com>d_t.bat
call d_t.bat
del d_t.com
del d_t.bat

echo century: %_cy%
echo year: %_yr%
echo month: %_mo%
echo day: %_da%
echo hour: %_hh%
echo minute: %_mm%
echo second: %_ss%

move c:\perflogs\networksops2.csv
c:\perflogs\archivedperflogs\networksops2%_cy%%_yr%%_mo%%_da%.csv
 
C

carla_cund

Hi

Thanks for your help. However I have put this into a file and saved as
a .bat file and get errors within in (added the pause function so i
could see what was happening)

errors :

C:\Documents and Settings\Carla.Cund\Desktop>move
c:\perflogs\networksops2.csv

The system cannot find the file specified.

C:\Documents and
Settings\Carla.Cund\Desktop>c:\perflogs\archivedperflogs\networ
ksops2.csv
'c:\perflogs\archivedperflogs\networksops2.csv' is not recognized as an
internal
or external command,
operable program or batch file.

Does this mean anyhting to you?

Thanks Again for all your help

carla
 
F

foxidrive

Hi

Thanks for your help. However I have put this into a file and saved as
a .bat file and get errors within in (added the pause function so i
could see what was happening)

errors :

C:\Documents and Settings\Carla.Cund\Desktop>move
c:\perflogs\networksops2.csv

The system cannot find the file specified.

C:\Documents and
Settings\Carla.Cund\Desktop>c:\perflogs\archivedperflogs\networ
ksops2.csv
'c:\perflogs\archivedperflogs\networksops2.csv' is not recognized as an
internal
or external command,
operable program or batch file.

Does this mean anyhting to you?

The following is on one line separated by a space, in the batch file - it
seems you have it on two lines.

move c:\perflogs\networksops2.csv
c:\perflogs\archivedperflogs\networksops2%_cy%%_yr%%_mo%%_da%.csv

Thanks Again for all your help

You're welcome.
 
C

carla_cund

Hi again

i had a closer look at the move code and it appears that the file was
mis spelt so that is the reason it couldnt find the specified file! :)

Now then. It has moved the file. But not added the date into the
filename here is what it has run through-no errors, successfully moved
file but not renamed:

C:\Documents and Settings\Carla.Cund\Desktop>d_t.com 1>d_t.bat
'd_t.com' is not recognized as an internal or external command,
operable program or batch file.

C:\Documents and Settings\Carla.Cund\Desktop>call d_t.bat

C:\Documents and Settings\Carla.Cund\Desktop>del d_t.com
Could Not Find C:\Documents and Settings\Carla.Cund\Desktop\d_t.com

C:\Documents and Settings\Carla.Cund\Desktop>del d_t.bat

C:\Documents and Settings\Carla.Cund\Desktop>echo century:
century:

C:\Documents and Settings\Carla.Cund\Desktop>echo year:
year:

C:\Documents and Settings\Carla.Cund\Desktop>echo month:
month:

C:\Documents and Settings\Carla.Cund\Desktop>echo day:
day:

C:\Documents and Settings\Carla.Cund\Desktop>echo hour:
hour:

C:\Documents and Settings\Carla.Cund\Desktop>echo minute:
minute:

C:\Documents and Settings\Carla.Cund\Desktop>echo second:
second:

C:\Documents and Settings\Carla.Cund\Desktop>move
c:\perflogs\networkops2.csv c:
\perflogs\archivedperflogs\networksops2.csv
The system cannot find the file specified.

C:\Documents and Settings\Carla.Cund\Desktop>pause
Press any key to continue . . .



Hope you can help!

thanks
Carla
 
C

carla_cund

Thanks for that, I have done that, and also found tha tthe actual name
of the file was wrong (ooops my fault) So the batch file moves the
file into the correct place, howeveer its not adding the date to the
filename- any ideas? Heres a copy of te script that its run


C:\Documents and Settings\Carla.Cund\Desktop>d_t.com 1>d_t.bat
'd_t.com' is not recognized as an internal or external command,
operable program or batch file.

C:\Documents and Settings\Carla.Cund\Desktop>call d_t.bat

C:\Documents and Settings\Carla.Cund\Desktop>del d_t.com
Could Not Find C:\Documents and Settings\Carla.Cund\Desktop\d_t.com

C:\Documents and Settings\Carla.Cund\Desktop>del d_t.bat

C:\Documents and Settings\Carla.Cund\Desktop>echo century:
century:

C:\Documents and Settings\Carla.Cund\Desktop>echo year:
year:

C:\Documents and Settings\Carla.Cund\Desktop>echo month:
month:

C:\Documents and Settings\Carla.Cund\Desktop>echo day:
day:

C:\Documents and Settings\Carla.Cund\Desktop>echo hour:
hour:

C:\Documents and Settings\Carla.Cund\Desktop>echo minute:
minute:

C:\Documents and Settings\Carla.Cund\Desktop>echo second:
second:

C:\Documents and Settings\Carla.Cund\Desktop>move
c:\perflogs\networkops2.csv c:
\perflogs\archivedperflogs\networkops2.csv

C:\Documents and Settings\Carla.Cund\Desktop>pause
Press any key to continue . . .

thanks

carla
 
F

foxidrive

Thanks for that, I have done that, and also found tha tthe actual name
of the file was wrong (ooops my fault) So the batch file moves the
file into the correct place, howeveer its not adding the date to the
filename- any ideas? Heres a copy of te script that its run


C:\Documents and Settings\Carla.Cund\Desktop>d_t.com 1>d_t.bat
'd_t.com' is not recognized as an internal or external command,
operable program or batch file.

This line shows that the top portion of the batch file where it looks like
an ascii jumble, is missing or corrupted.

Copy and paste the code from the message again.
 
C

carla_cund

I fi cope all of the message again and insert it, I recieve a 16 bit
ms-dos subsystem error. It states

The NTVDM CPU has encountered an illegal instruction. Choose close to
terminate the application.


If i select ignore it still copies the file from the directory to the
other directory but still doesnt rename it. Any ideas? :)
 
F

foxidrive

I fi cope all of the message again and insert it, I recieve a 16 bit
ms-dos subsystem error. It states

The NTVDM CPU has encountered an illegal instruction. Choose close to
terminate the application.


If i select ignore it still copies the file from the directory to the
other directory but still doesnt rename it. Any ideas? :)

It's hard to say - did you paste the message into Notepad and save it?
 
C

carla_cund

hi

Yes i have copied all this into a notepad and saved as batch.bat ,
double clicked and the error appears. I am running Windows XP, will
this be a factor?

@echo off
:: Code by Herbert Kleebauer
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>d_t.com

echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY
Wv;ovBX2Gv0ExGIuht6>>d_t.com
echo
LisqMz`wGH@wKuur`G@w?ogBgGG}G?j_egoNOG?w?`gBLksqgG`w?WgBgG>>d_t.com
echo
G}G?R_MgoNMy?wSx@W?s?W?@zAB`LrFuBLyt~vuco{@LuKooD?BFHqrIcP>>d_t.com
echo
_sdDxb1T??=?rILO_sdDqx1T??=?rILO_sdDnl1T??=?rILO_sdD`c1T??>>d_t.com
echo
=?rILO_sdDgg1T??=?rILO_sdDll1T??=?rILO_sdDrr1T??=??IL?0xxx>>d_t.com


d_t.com>d_t.bat
call d_t.bat
del d_t.com
del d_t.bat


echo century: %_cy%
echo year: %_yr%
echo month: %_mo%
echo day: %_da%
echo hour: %_hh%
echo minute: %_mm%
echo second: %_ss%


move c:\perflogs\networksops2.csv
c:\perflogs\archivedperflogs\networksops2%_cy%%_yr%%_mo%%_da%.csv
 
F

foxidrive

Yes i have copied all this into a notepad and saved as batch.bat ,
double clicked and the error appears. I am running Windows XP, will
this be a factor?

No, I am using XP. It should work in any Windows system.

Does your batch file look like this at the beginning? 8 lines?

@echo off
:: Code by Herbert Kleebauer
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>d_t.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>d_t.com
echo LisqMz`wGH@wKuur`G@w?ogBgGG}G?j_egoNOG?w?`gBLksqgG`w?WgBgG>>d_t.com
echo G}G?R_MgoNMy?wSx@W?s?W?@zAB`LrFuBLyt~vuco{@LuKooD?BFHqrIcP>>d_t.com
echo _sdDxb1T??=?rILO_sdDqx1T??=?rILO_sdDnl1T??=?rILO_sdD`c1T??>>d_t.com
echo =?rILO_sdDgg1T??=?rILO_sdDll1T??=?rILO_sdDrr1T??=??IL?0xxx>>d_t.com


@echo off
:: Code by Herbert Kleebauer
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>d_t.com

echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY
Wv;ovBX2Gv0ExGIuht6>>d_t.com
echo
LisqMz`wGH@wKuur`G@w?ogBgGG}G?j_egoNOG?w?`gBLksqgG`w?WgBgG>>d_t.com
echo
G}G?R_MgoNMy?wSx@W?s?W?@zAB`LrFuBLyt~vuco{@LuKooD?BFHqrIcP>>d_t.com
echo
_sdDxb1T??=?rILO_sdDqx1T??=?rILO_sdDnl1T??=?rILO_sdD`c1T??>>d_t.com
echo
=?rILO_sdDgg1T??=?rILO_sdDll1T??=?rILO_sdDrr1T??=??IL?0xxx>>d_t.com

Your paste above looks quite different in comparison.
 
C

carla_cund

Hi

My batch file is exactly the same as the one you posted, here is a copy
whilst in edit mode of the batch file


@echo off
:: Code by Herbert Kleebauer
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>d_t.com

echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY
Wv;ovBX2Gv0ExGIuht6>>d_t.com
echo
LisqMz`wGH@wKuur`G@w?ogBgGG}G?j_egoNOG?w?`gBLksqgG`w?WgBgG>>d_t.com
echo
G}G?R_MgoNMy?wSx@W?s?W?@zAB`LrFuBLyt~vuco{@LuKooD?BFHqrIcP>>d_t.com
echo
_sdDxb1T??=?rILO_sdDqx1T??=?rILO_sdDnl1T??=?rILO_sdD`c1T??>>d_t.com
echo
=?rILO_sdDgg1T??=?rILO_sdDll1T??=?rILO_sdDrr1T??=??IL?0xxx>>d_t.com


d_t.com>d_t.bat
call d_t.bat
del d_t.com
del d_t.bat


echo century: %_cy%
echo year: %_yr%
echo month: %_mo%
echo day: %_da%
echo hour: %_hh%
echo minute: %_mm%
echo second: %_ss%


move c:\perflogs\networkops2.csv
c:\perflogs\archivedperflogs\networkops2%_cy%%_yr%%_mo%%_da%.csv



pause


I cant understand how it can work fine in your system, but not in mine,
I cant see if theres anything im doing wrong as i have just done a
complete copy

Sorry this is taking so much of your time

thanks
Carla
 
C

carla_cund

This is rather strange , my bat file looks exactly like you paste it,
however when i copy, and paste into either ms word, or this browser it
pastes it looking differently. The actual bat file looks the same as
your code tho.

Strange...
 
F

foxidrive

Try this instead. I thought the ascii binary would be simpler but it's not
for those using google groups, as google groups is known to cause issues
when copying code from their pages.

Remember to unwrap the last line.

@echo off
:: from code by Phil Robyn
setlocal
echo >"%temp%\%~n0.vbs" s=DateAdd("d",0,now)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^&_
echo>>"%temp%\%~n0.vbs" right(100+month(s),2)^&_
echo>>"%temp%\%~n0.vbs" right(100+day(s),2)
for /f %%a in (
'cscript //nologo "%temp%\%~n0.vbs"') do set result=%%a
del "%temp%\%~n0.vbs"
endlocal& set day=%result:~0,4%-%result:~4,2%-%result:~6,2%
move c:\perflogs\networksops2.csv
c:\perflogs\archivedperflogs\networksops2%day%.csv
 
C

carla_cund

I am now recieving

The syntax of the command is incorrect

Should i type the code out , or perhaps you could email it me over?
 
P

Phil Robyn

This is rather strange , my bat file looks exactly like you paste it,
however when i copy, and paste into either ms word, or this browser it
pastes it looking differently. The actual bat file looks the same as
your code tho.

Strange...

Carla, don't use MS Word to edit batch files; use Notepad instead.
 
T

Todd Vargo

I fi cope all of the message again and insert it, I recieve a 16 bit
ms-dos subsystem error. It states

The NTVDM CPU has encountered an illegal instruction. Choose close to
terminate the application.


If i select ignore it still copies the file from the directory to the
other directory but still doesnt rename it. Any ideas? :)

Please read the following.

How can I automatically quote the previous message when I post a reply?
http://groups.google.com/support/bin/answer.py?answer=14213
 
C

carla_cund

Thanks Everyone for all your kind help! This site is fantastic and
contain a wealth of knowledge!!

thanks techies!

Carla
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top