I am currently using a batch file that uses the following code
@ECHO off
XCOPY /y C:\ProCal\Certificates\ProResDB.mdb H:\onsite\Imports\
@ECHO on
to copy one file (ProResDB.mdb) from the folder 'C:\ProCal\Certificates\' to a the folder 'H:\onsite\Imports\'. How can I add the current date and a predefined initial to the filename of the copied file?
Example: ProResDBddmmyyXX.mdb
Alternatively if this can be done in VBScript, feel free to offer suggestions of how to script that.
- Follow via:
- RSS
- Email Alert
Question
0
Votes
How to change filename of file copied in xcopy batch file?
Updated - 13th Apr 2011
Answers (3)
1
Vote
For my log files, I use the following code
@echo off
rem get date, make if file name friendly
FOR /F "tokens=1-4 delims=/ " %%i in ('date/t') do set d=%%j-%%k-%%l@%%i@
rem get time, make if file name friendly
FOR /F "tokens=1-9 delims=:. " %%i in ('time/t') do set t=%%i_%%j_%%k%%l
set LOG=%d%%t%.log
ren dump.log %log%
move *.log c:\snort\log\sav
echo YOUR FILE NAME IS : %log%
rem get date, make if file name friendly
FOR /F "tokens=1-4 delims=/ " %%i in ('date/t') do set d=%%j-%%k-%%l@%%i@
rem get time, make if file name friendly
FOR /F "tokens=1-9 delims=:. " %%i in ('time/t') do set t=%%i_%%j_%%k%%l
set LOG=%d%%t%.log
ren dump.log %log%
move *.log c:\snort\log\sav
echo YOUR FILE NAME IS : %log%
13th Apr 2011
Replies
Thanks for your reply Robo.
So incorporating that into mine - it kind of does what I need it to do - copy and rename and move. However, the filename I get is: "04-2011-@14@10_33_"
Is there any way to get this to be "ProResDB-dd-mm-yy-hh-mm.mdb"?
Or, without the time and with predefined initials at the end of the filename eg: "ProResDB-dd-mm-yy-ME.mdb"
@ECHO off
XCOPY /y C:\ProCal\Certificates\ProResDB.mdb
rem get date, make if file name friendly
FOR /F "tokens=1-4 delims=/ " %%i in ('date/t') do set d=%%j-%%k-%%l@%%i@
rem get time, make if file name friendly
FOR /F "tokens=1-9 delims=:. " %%i in ('time/t') do set t=%%i_%%j_%%k%%l
set MDB=%d%%t%.mdb
ren ProResDB.mdb %mdb%
move *.mdb H:\Onsite\Imports\
@ECHO on
So incorporating that into mine - it kind of does what I need it to do - copy and rename and move. However, the filename I get is: "04-2011-@14@10_33_"
Is there any way to get this to be "ProResDB-dd-mm-yy-hh-mm.mdb"?
Or, without the time and with predefined initials at the end of the filename eg: "ProResDB-dd-mm-yy-ME.mdb"
@ECHO off
XCOPY /y C:\ProCal\Certificates\ProResDB.mdb
rem get date, make if file name friendly
FOR /F "tokens=1-4 delims=/ " %%i in ('date/t') do set d=%%j-%%k-%%l@%%i@
rem get time, make if file name friendly
FOR /F "tokens=1-9 delims=:. " %%i in ('time/t') do set t=%%i_%%j_%%k%%l
set MDB=%d%%t%.mdb
ren ProResDB.mdb %mdb%
move *.mdb H:\Onsite\Imports\
@ECHO on
Dale27
14th Apr 2011
0
Votes
Got it working...
@ECHO off
XCOPY /y C:\ProCal\Certificates\ProResDB.mdb
rem get date, make if file name friendly
FOR /F "tokens=1-4 delims=/ " %%i in ('date/t') do set d=%%i-%%j-%%k-%%l
set MDB=ProResDB%d%DN.mdb
ren ProResDB.mdb %mdb%
move *.mdb H:\Onsite\Imports\
@ECHO on
Copies the file C:\ProCal\Certificates\ProResDB.mdb, renames the file with the date and initials and moved to H:\onsites\imports\
Thanks for your help Robo
XCOPY /y C:\ProCal\Certificates\ProResDB.mdb
rem get date, make if file name friendly
FOR /F "tokens=1-4 delims=/ " %%i in ('date/t') do set d=%%i-%%j-%%k-%%l
set MDB=ProResDB%d%DN.mdb
ren ProResDB.mdb %mdb%
move *.mdb H:\Onsite\Imports\
@ECHO on
Copies the file C:\ProCal\Certificates\ProResDB.mdb, renames the file with the date and initials and moved to H:\onsites\imports\
Thanks for your help Robo
14th Apr 2011
0
Votes
Amazing when things
just work
14th Apr 2011

































