Solved

How to rename a file name to a prefix + current date in DOS batch file

Posted on 2000-03-20
8
17,373 Views
Last Modified: 2010-04-30
Hi

My machine is an NT.  Everyday, there will be a file (i.e. abc.txt) output to my NT server & I need to write a program (in DOS batch file) to rename the file from abc.txt to abc210300.txt

The 210300 means 21st March 2000, if today is 21/3/2000.  So, everyday the program will be scheduled to run and reanme the abc.txt to

"abc" + current date + ".txt"

This is the batch file commands I have now, but I don't know how to put in the date portion.  

@echo off
echo.

rename c:\temp\abc.txt abc123.txt

@echo off


Thank you.
n_chai
0
Comment
Question by:n_chai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 3

Expert Comment

by:vikiing
ID: 2644810
You will need the help of a tiny program (I can write it for you) to accomplish that job.

Unfortunately, there is no way to do what you need directly from DOS commands; thus, it's impossible to write a .BAT program that make that.
0
 

Accepted Solution

by:
viper5by5 earned 30 total points
ID: 2659925
there is no way to write a batch file(*.BAT, with out using some sort of program.

I could wirte the program for you, use some programs i have at home.
0
 
LVL 1

Expert Comment

by:guyss
ID: 2659936
you can use the 4NT shell instead of cmd.exe

then you'll be able to do these things.
4NT is available from
http://www.jpsoft.com
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Expert Comment

by:Somebody_else
ID: 2687245
you can wirte code in a text file and save it as file.bat and it will be a batch file.
0
 

Expert Comment

by:plusign
ID: 2776183
You can try this site

http://www.calweb.com/~webspace/batch/sa
mples/namedate.txt
0
 
LVL 11

Expert Comment

by:saragani
ID: 2924605
I can build a little program for you in GWBASIC and it will work fine.
0
 
LVL 3

Expert Comment

by:vikiing
ID: 2924911
Forget it, dude; it seems to be nobody there... :(
0
 

Expert Comment

by:temadan
ID: 12471024
Hello
This works for the batch file (.bat) file in MS-DOS on Win2000.

for "abc" + current date + ".txt" you will have to add the code
%date:~4,2%-%date:~7,2%-%date:~10%
at the place you want your current date to appear.

e.g.
ren c:\temp\abc.txt abc%date:~4,2%-%date:~7,2%-%date:~10%.txt

Enjoy :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are interested in the gaming world and want to try World of Warcraft, I'd recommend this basic set of add-ons to get you started.  All add-ons are available either by Google search or on Curse.com. For the person who doesn't want to get in…
As we all know Counter Strike is a very popular computer game. Usually it is played over a network for which people create a server and users join it but it is interesting to know that one can creates a dedicated server which not only hosts the game…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question