Search : in
By :

DOS: create filename based on date?

Last answer on Jul 30, 2009 7:11:51 pm BST whitedog1, on Jul 24, 2009 1:33:11 pm BST 
 Report this message to moderators

Hello,

I need to be able to automatically generate a DOS .txt filename that is the 'date' of when it is created.

Any ideas? My DOS is rather rusty and have run out of ideas.

Configuration: Windows XP Internet Explorer 7.0  (XP Dos)

Best answers for « DOS: create filename based on date? » in :
MS DOS Files and directories Show Files in MS DOS In a computers data is stored in files. When you run a program, MS-DOS processes the data stored in the file and passes it to the system. In MS-DOS a file can be any size, however the file name is more restricted, it can only have...
Basic MS-Dos commands Show Basic MS-Dos commands Intro The command prompts: Intro Here is a list of basic commands that you can use in a DOS prompt (e.g. a using a boot disk). To have additional information about these commands, type /? after entering the...
Connect a database (MDB) to excel Show[VBA] Connecting a database (MDB) to excel Below is a tips of how to connect an Access database (MDB) in an application excel Add reference Microsoft DAO object librairy X.X In a general module (eg Module1) paste the code below...
Create your own command on linux ShowCreate your own command on linux Creating a Bash script Turning the command active (Executable) Creating a Bash script It’s important to create a Bash script which will run your command. Let’s see: #!/bin/bash #on displays the...
[Shell]Create a file having a specific size ShowShell]Create a file having a specific size The dd command allows you to create "empty" file of desired size, creating these arbitrary heavy files, may be useful for testing purposes. Use command below: dd if=/dev/zero of=file_to...
Download Infra Recorder ShowInfra Recorder is a free CD-DVD software burning for Microsoft Windows systems. It offers a large number of features via an intuitive interface and an integration to the system menus : - Creation of audio data or mixed CD / DVD. - Creation of ISO...
Ping of death attack ShowPing of death attack The ping of death attack is one of the oldest network attacks. The principle of ping of death simply involves creating an IP datagram whose total size exceeds the maximum authorized size (65,536 bytes). When such a packet is...
Introduction to DOS ShowThe development of MS-DOS MS-DOS is the most well known operating system, the most commercialised version is that of Microsoft, christened "MS-DOS" (there are other versions such as DR-DOS). MS-DOS was created in 1981 when it was used on an IBM...
Operating Systems - MS-DOS - Commands ShowCommand Description dir lists the contents of a folder cd changes folder cd .. parent folder md or mkdir creates a new folder deltree deletes a folder and all sub-folders copy, xcopy copies...

1

mildman, on Jul 24, 2009 2:09:07 pm BST

Try this:

copy con %DATE%.txt

the press Ctrl-Z.

This will create a zero-length file named 24-Jul-2009.txt (or whatever).

Reply to mildman

2

mildman, on Jul 24, 2009 2:12:25 pm BST

Sorry, that won't work from a batch file! If you don't mind what is in the file then this will work:

echo >%DATE%.txt

And if a zero-length file is important to you then create one manually as described before, then use:

copy yourZeroLengthFile %DATE%.txt

Reply to mildman

3

sandbeha, on Jul 30, 2009 7:11:41 pm BST

You might try something like this...


set filea=MyBigFile%date:~10%%date:~4,2%%date:~7,2%%time:~0,2%%t­ime:~3,2%.sav
copy MyData.dat %filea%

Since the date is Thu 07/30/2009 and the time is 14:07:00.00,
For today this would give a file named
MyBigFile200907301407.sav

good luck

Reply to sandbeha

4

 sandbeha, on Jul 30, 2009 7:11:51 pm BST

You might try something like this...


set filea=MyBigFile%date:~10%%date:~4,2%%date:~7,2%%time:~0,2%%t­ime:~3,2%.sav
copy MyData.dat %filea%

Since the date is Thu 07/30/2009 and the time is 14:07:00.00,
For today this would give a file named
MyBigFile200907301407.sav

good luck

Reply to sandbeha