Solved

Create files named (YYMMDD.txt) with batch file !!

Posted on 2007-04-10
3
549 Views
Last Modified: 2010-04-18
Hi

How Can I create batch file do the following operation ??

I have this file (C:\Database.txt) it’s dally created in the same location

I need to copy this file every day after I double click the batch file to new location with new file name format
C:\backup\070410.txt
C:\backup\070411.txt
C:\backup\070412.txt
C:\backup\070413.txt

As you can see the it’s in this format (YYMMDD.txt)

So how Can I create batch file can copy file to new location with new file name format ??

Thanks with my regarding
0
Comment
Question by:Fraas
  • 3
3 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18881421
set year=%date:~12%
set month=%date:~4.2%
set day=%date:~7,2%
copy c:\database.txt c:\backup\%year%%month%%day%.txt
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18881435
Or, if you wanted the full year, you could do it this way:

for /f "tokens=2-3* delims=/ " %%a in ("%date%") do copy c:\database.txt c:\backup\%%c%%a%%b
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18883456
Thanx!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to execute all sub dir 2 41
Backup DHCP Server 8 115
Unexpected Windows system folders on D drive 16 88
Coding yesterday's date 3 37
Learn about cloud computing and its benefits for small business owners.
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

829 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