1.

Solve : Make directory using current date?

Answer»

Hi everyone, my FIRST post!
It would be great if anyone could give me a hand in making a batch file.

My operating system is Windows 98SE
(Windows 98 version 4.10.2222)

I am intending to have the batch file on the desktop.
I would love it to be ABLE to:

1) Make a new directory inside of “C:\My Documents\folder”, using the current date and time as the name of the new folder. So an example would be: C:\My Documents\folder\%SomeDateTimeFormat%

2) Move all files from “C:\Test\TestFolder”, to the newly created folder of: %SomeDateTimeFormat% (inside of C:\My Documents\folder).

I hope that this is not too hard and I look forward to your suggestions.
Thanks in advance
Quote

Hi everyone, my first post!
It would be great if anyone could give me a hand in making a batch file.

My operating system is Windows 98SE
(Windows 98 version 4.10.2222)

I am intending to have the batch file on the desktop.
I would love it to be able to:

1) Make a new directory inside of “C:\My Documents\folder”, using the current date and time as the name of the new folder. So an example would be: C:\My Documents\folder\%SomeDateTimeFormat%

2) Move all files from “C:\Test\TestFolder”, to the newly created folder of: %SomeDateTimeFormat% (inside of C:\My Documents\folder).

I hope that this is not too hard and I look forward to your suggestions.
Thanks in advance


I don't know how hard it is what I have asked for, would it be easier if I just asked for the new folder named with just the "today's date" and not the time also?

Thanks again and I look forward to any replyhi
do a search first in this forum. enter "date time" as the search KEYS, show entries for the last 3 MONTHS , or last 1 year and you can find some posts that shows how to manipulate dates/times in batchDate and time manupilation is not easy under Windows 98 DOS. It is very easy to do under Windows 2000 and newer.

Date only is easier. I think most (or all) of the posts you will find on doing this are for Windows NT/2000/XP/2003.

Give me a few minutes, and I'll post some code that can do it in Windows 98 ... but it won't be pretty.This assumes that the directory "C:\My Documents\folder" already exists:
Code: [Select]@echo off
echo. |date >date.txt

echo e 100 >debug.txt
echo 73 65 74 20 64 61 74 65 73 74 72 3d >>debug.txt
echo m 11a 11d 10c >>debug.txt
echo m 114 115 110 >>debug.txt
echo m 117 118 112 >>debug.txt
echo rcx >>debug.txt
echo 14 >>debug.txt
echo n datestr.bat >>debug.txt
echo w >>debug.txt
echo q >>debug.txt

debug date.txt <debug.txt
del date.txt
del debug.txt
call datestr.bat
echo Date is %datestr%
del datestr.bat

md "C:\My Documents\folder\%datestr%"
move "C:\Test\TestFolder\*.*" "C:\My Documents\folder\%datestr%"GuruGary,

Thanks very much for your help.
I thought that it would be a difficult thing to do under win98.
Yes, I have seen plenty of code for the newer OS’s.

Thanks again
No problem. Did it work the way you wanted? Or even work at all?If batch is not easy to manipulate dates and time, why not go for scripting langauges like VB, perl, python? date and time manipulation is easier. here's a simple one in python

Code: [Select]import time,os,shutil
thedate = time.strftime("%Y%m%d",time.localtime()) #only get the date, not time
rootdir = os.path.join("C:\\", "My Documents" , "folder")
newfolder = os.path.join(rootdir,thedate)
testfolder = os.path.join("C:\\", "Test" ."TestFolder")
os.makedirs(newfolder)
os.chdir(testfolder)
for files in os.listdir(testfolder):
shutil.move(files,newfolder)

its easier to understand ...Thanks to GuruGary, the Batch worked great!
Thanks too to ghostdog74, for writing the Python script!
It's nice to know that there are people out there that still like to help.
All for free too!
Have a good day
Cheers


Discussion

No Comment Found