Help with .bat

G

Guest

Hi forum people, first of all sorry for my english, now the subject: i
changed the bat of the MS Support page to print the directory list in order
to keep it in a file .txt and then to be possible to modify the content. The
new bat is:
echo off
dir %1 /-p /o:gn > "C:\files\Directory List.txt"
exit
and it run ok, but i wld need that the bat gives a new name to the .txt in
each ocassion (ie to add date & time at name "Directory List.txt") in order
not to clean previus file.
Is it possible to do that? & how??
Thks in advance for your help.
Rgds
Carlos
Buenos Aires - Argentina
 
S

Special Access

Hi forum people, first of all sorry for my english, now the subject: i
changed the bat of the MS Support page to print the directory list in order
to keep it in a file .txt and then to be possible to modify the content. The
new bat is:
echo off
dir %1 /-p /o:gn > "C:\files\Directory List.txt"
exit
and it run ok, but i wld need that the bat gives a new name to the .txt in
each ocassion (ie to add date & time at name "Directory List.txt") in order
not to clean previus file.
Is it possible to do that? & how??
Thks in advance for your help.
Rgds
Carlos
Buenos Aires - Argentina


you could add this:

echo off
echo %date% >> (filename)
echo %time% >> (filename)
dir %1 /-p /o:gn >> (filename)
echo . >> (filename)
exit

The additional lines, and the double-pipe will insert the date and
time into the existing file and not overwrite it.
Not exactly what you asked for, but it might work for you.

Mike
 
G

Guest

not really sure but is this what your trying to do:

@echo off
setlocal
for /f "tokens=1-8 delims=:/-. " %%a in ("%date% %time%") do (
set dayname=%%a
set month=%%b
set day=%%c
set year=%%d
set hour=%%e
set minute=%%f
set second=%%g
set millisecond=%%h
)
dir %1 /-p /o:gn >"c:\files\%dayname%
%month:~0,-1%-%day:~0,-1%-%year:~0,-1%
%hour:~0,-1%-%minute:~0,-1%-%second:~0,-1%-%millisecond:~0,-1%_directory
list.txt"
endlocal

*lines that dont begin with 2 spaces have accidentally wrapped*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

BAT File to Run 3 Programs 4
Renaming the filename without '-' 0
Bat files 2
Creating a .bat file? 43
bat calling vbscript 1
Running a BAT file with Access 5
execute an access formulari with .bat 0
Windows XP Batch file editing 0

Top