Solved

Adding todays date to file names

Posted on 2008-10-07
7
329 Views
Last Modified: 2010-04-16
Is there an easy way to add todays date to file names using .CMD

I want to copy all the files in a folder and create copies with today's date added to the file name

The folder would contain
test.txt
test2.txt
and after running the .cmd file the folder would contain
test.txt
test2.txt
test10072008.txt
test10072008.txt

thanks for the help
 
0
Comment
Question by:derekstattin
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 5

Accepted Solution

by:
si_shamil earned 255 total points
ID: 22665037
copy & paste this code to CMD file
@echo off
for %%i in (*.txt) do (copy %%i %%~ni%date:~-10,2%%date:~-7,2%%date:~-4,4%.txt)

Open in new window

0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 245 total points
ID: 22665087
or a shorter method...
xcopy "*.txt" "*%date:/=%.*"

Open in new window

0
 

Author Comment

by:derekstattin
ID: 22665256
I did not have any results from sir bounty's solution, but si_shamils works.

Is there a way to add dashes into the code 10-07-2008?

thanks for the help on the other question as well

I am a beginner and I am trying to build the peices so I understand how to achieve the outcome I am looking for. I will post a couple more question that will build on your answers
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 5

Assisted Solution

by:si_shamil
si_shamil earned 255 total points
ID: 22665268
with dashes:
@echo off
for %%i in (*.txt) do (copy %%i %%~ni%date:~-10,2%-%date:~-7,2%-%date:~-4,4%.txt)

Open in new window

0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 245 total points
ID: 22665275
Had a type-o in my code...try this:
xcopy "*.txt" "%date:/=-%.*"

Open in new window

0
 

Author Comment

by:derekstattin
ID: 22665313
Thanks for the help,
I will post another question shorlty
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

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