Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a New Folder - with scheduler? 2

Status
Not open for further replies.

theripper

MIS
Aug 12, 1999
341
US
I have a customer that would like their NT Server to create a new folder each day automatically from scheduler.<br>
<br>
They would like the folder to simply be named with the date.<br>
<br>
I can not find anywhere that allows this. Any suggestions?<br>
<br>
Thanks in advance!
 
There is an environment variable %date% which prints the date as &quot;Thu 12/30/99&quot;, however if you use this in the &quot;mkdir&quot; command (mkdir %date%) you get &quot;The syntax of this command are incorrect&quot; becuase of the &quot;/&quot; (doing &quot;mkdir %username%&quot; does create a directory with the user name, so you can use environment variables with the mkdir command)... however, you need to get rid of the &quot;/&quot; some way...<br>
<br>
I know in *NIX you can use cut or use sed to replace characters within a pipe command or script.<br>
<br>
So to answer your question -- you can use the at command to schedule the command, and the command can be &quot;mkdir %date%&quot;, but you need to do some replacement or removal of the resulting &quot;/&quot;. I don't know, check the Resource Kit, possibly use a simple Perl script, shouldn't be to bad of a script.
 
I hate to be a Kiljoy here Ripper, but exactly WHY do they want this directory and what are they going to put into it?<br>
<br>
Is there another way of doing it for instance?<br>
<br>
By the way, NT4 SP5 - if you type md %date% you get a directory called %date%.<br>
<br>
Wierd stuff.
 
Thanks for the replies.<br>
<br>
Zelandakh - The customer uses a pretty big document imaging system. They would like for their data entry employees to login, and look in the created folder (ie 122099) to view all new documents that need to be scanned and processed for that business day. They simply create the folder manually each morning now.
 
My fault, I tried what I said on a Windows 2000 machine - that's where you get the syntax error --- sorry. The %username% does work though... %date% is a new environment variable in Win2000 I guess, sorry...<br>
<br>
You could possibly use &quot;net time&quot; in a batch file/script and cut the extra info off and change the &quot;/&quot;...<br>
<br>
Also the command &quot;date /t&quot; displays the date as in &quot;Thu 12/30/99&quot;....<br>
<br>
Alright, here is a simple Perl script to do the job... No I do not do Perl programming for a living, so no cracks on the coding - it works...<br>
<br>
#!d:/resource kit/nt4/perl/perl.exe<br>
<br>
$date=`date /t`;<br>
<br>
$date=~s/Mon ¦Tue ¦Wed ¦Thu ¦Fri ¦Sat ¦Sun //gi;<br>
$date=~s/\///g;<br>
<br>
print `mkdir $date`;<br>
<br>
Probably have to add the full path name in the print `mkdir...`; statement....
 
The following NT batch file will give you the string you want. (My system has the medium date formatted to MM/dd/yyyy so my result is &quot;12311999&quot;).<br>
<br>
for /f &quot;tokens=2&quot; %%i in ('date /t') do set CURRDATE=%%i<br>
set CURRDATE=%CURRDATE:/=%<br>
echo %CURRDATE% <p> Jeff<br><a href=mailto: masterracker@hotmail.com> masterracker@hotmail.com</a><br><a href= > </a><br>
 
Thanks for the reply Jeff.<br>
<br>
Where would the output be for the above listed batch? Or, lets say I wanted the path to be f:\this\server<br>
Where in the above batch would I specify the path?<br>
<br>
I haven't worked with batch files much, so all the tips/info you can give me is greatly appreciated.<br>
<br>
Thanks again!
 
============================<br>
@echo off<br>
rem DateFolder.bat - Create folder from current date<br>
<br>
set FOLDROOT=F:\This\Server<br>
<br>
for /f &quot;tokens=2&quot; %%i in ('date /t') do set CURRDATE=%%i<br>
set CURRDATE=%CURRDATE:/=%<br>
<br>
md %FOLDROOT%\%CURRDATE%<br>
=============================<br>
<br>
Today the above will create &quot;F:\This\Server\01032000&quot; <p> Jeff<br><a href=mailto: masterracker@hotmail.com> masterracker@hotmail.com</a><br><a href= > </a><br>
 
Hey Jeff ~<br>
<br>
Worked like a charm. Thanks a ton!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top