Solved

Adding todays date to file names

Posted on 2008-10-07
7
327 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
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
 

Author Comment

by:derekstattin
ID: 22665449
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

732 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