Solved

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

Posted on 2007-04-10
3
548 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows-Based File Server (SMB) and Point in Time Backups (Shadow Copy?) 10 72
robocopy vs xcopy vs copy 8 110
Robocopy command line 6 55
2003 File Server upgrade 11 62
Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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…

776 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