1.

Solve : Batch file to change filename?

Answer»

I've been using a batch file with the following code to copy a file from one location to another :

Code: [Select]XCOPY R:\CYPAYDTA\Bacsfile.seq "S:\PAYROLL\" /Y
EXIT

I now need to be ABLE to copy the file to the same location but change the name to Bacsfile_Date.seq

Any ideas anyone please?if you just need to change the name the command your looking for is 'rename' type Code: [Select] ren [DRIVE:][path]filename1 filename2
Also there is an MSDOS section of the forum that will be better suited to any more DOS/batch related questions you have.


FBCan you steal something from this? http://www.ericphelps.com/batch/samples/ntdate.bat.txt

Edit: Nevermind. Got it.

Source: http://www.computing.net/answers/dos/rename-file-using-date/14569.html

Code: [Select]XCOPY R:\CYPAYDTA\Bacsfile.seq "S:\Payroll\" /Y
REN S:\Payroll\Bacsfile.seq Bacsfile%date:~4,2%-%date:~7,2%-%date:~10%.seq
EXIT
It turned my test.txt in to test10-23-2008.txt



Discussion

No Comment Found