- Want .bat code for New Menu option for "Folder" [CurrentDate] in the R-Click of Window Explorer.
- Posted by kakasay on January 17th, 2007
Want a batch code for the Mew menu option for "Folder" with current
date in the R-Click of Window Explorer.
- Posted by Tom Lavedas on January 17th, 2007
I would do it with a WSH script, but you asked for a batch file ...
This script requires WinNT or later because of the date parsing. Oh,
and because of the use of the /D switch with the CD statement late in
the procedure - and the conversion of single backslashes into doubles.
(All the more reason to use a WSH script - it would be appropriate
accross a wider spectrum of OS versions.)
::--------------------------8<-------------------------
:: MakeDatedFolder.cmd
::
:: Tom Lavedas, 17 Jan 2007
::
@echo off
::
:: Check to see if this is the first time procedure is run
::
set KeyName=HKEY_CLASSES_ROOT\Folder\shell\DateFolder
if exist %temp%\regout.txt del %temp%\regout.txt
regedit /e %temp%\regout.txt %KeyName%
if exist %temp%\regout.txt goto GetDate
::
:: Self installation on first execution
:: (New folder is NOT created)
::
set Batch=%~fnx0
set CommandText=\"%Batch:\=\\%\" \"%%1\"
del %temp%\regin.txt
echo "Registration of MakeDatedFolder is complete"
pause
goto :EOF
:GetDate
:: Clean up
for %%a in (Batch CommandText KeyName) do (set %%a=)
if exist %temp%\regout.txt del %temp%\regout.txt
:: Build folder name with today's date
::
for /f "tokens=2-4 delims=/ " %%a in ("%date%") do (
set FolderName=Folder_%%c%%a%%b)
:: Create the new folder's pathspec
::
if not [%1]==[] (
cd /d %1
md %FolderName%
cd %FolderName%
) else (
echo Unexpected error condition - no input argument
echo Nothing was done
pause
goto :EOF
)
::---------------------------8<---------------------
Save the procedure in an appropriate place and run it from that
location once and it will create the requisite registration entries.
After that, a right click menu item named "New Dated Folder" will
exist.
The main problem with this approach is that it will cause a console
window to appear very briefly each time it runs. I don't know of a way
to keep this from happening without using a WSH script (I wrote one,
but it's way off topic here).
Tom Lavedas
============
http://members.cox.net/tglbatch/wsh/
kakasay wrote:
- Posted by kakasay on January 18th, 2007
HI,
Thanks for Your Code.
I am using Windows 2000 Professional and i executed the code as
NewDateFolder.cmd in command prompt and found that When
i Right-click on any folder, this "New Dated Folder" comes and on
hitting its goes to command prompt and showing the below message.
and then i cant find the New folder Created!!!!!!.
"Registration of MakeDatedFolder is complete"
Press any key to continue . . ."
Note: i want this as a batch file as "NewDateFolder.bat", and my need
is R-click on Window Explorer, i want "New Folder" menu and not on
selecting a folder and R-Click.
Tom Lavedas wrote:
- Posted by Michael Bednarek on January 18th, 2007
On 17 Jan 2007 03:09:57 -0800, kakasay wrote in alt.msdos.batch:
This works here (under 4NT); other languages might require a more
elaborate approach.
MD "%&\%_ISODATE"
Creates a directory below the right-clicked directory in the form
YYYY-MM-DD. I use it a lot.
--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"