?
Solved

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

Posted on 2000-03-20
8
Medium Priority
?
17,406 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 60 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

See the related links at the bottom of the tutorial for downloads and supplemental information. Introduction The Nvidia 3D Vision Kit is a [not so] new gaming technology which allows you to play the newest computer games in "Stereo 3D" (like …
For those of you searching for a fun but also medium paced MMORPG game I would highly suggest Ragnarok Online. This MMORPG is a bit older than World of Warcraft and in a way is extremely different. Compared to WoW's 3D environment and massive wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month12 days, left to enroll

752 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