Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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,446 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
What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Author Cited: Konstantinos Dimopoulos URL Cited From: Article from Indie Games: http://indiegames.com/2012/07/browser_game_pick_the_grid.html The Grid (http://codeelf.com/games/grid/) is the sort of game I haven't played in over 10 years. It is …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

636 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