I added a "Create Date Folder" option to my context menu which calls a batch script. Basically, I right click on any background and then click on the "Create Date Folder" option and it creates a folder with the name in this format YYYYMMDD-XXX, where XXX are initials of the person creating the folder. In my case it will be LS. Everything was working fine until someone tried it on a UNC path (No letter network path) and it didn't work. I am just wondering if I can do something to my code to make it work with UNC paths.
I read about deactivating a safety register or something like that but I would like to enter code here
take a safe approach. Also, I have tried the pushd and popd commands but it creates the folder where that batch file is and I want it to create it where I do the right click.
Here is my register:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\Date Folder]
@="Create Date Folder"
[HKEY_CLASSES_ROOT\Directory\Background\shell\Date Folder\command]
@="D:\\Scripts\\getdate.bat"
Here my batch script:
@echo off
setlocal
rem get the date
rem use findstr to strip blank lines from wmic output
for /f "usebackq skip=1 tokens=1-3" %%g in (`wmic Path Win32_LocalTime Get Day^,Month^,Year ^| findstr /r /v "^$"`) do (
set _day=00%%g
set _month=00%%h
set _year=%%i
)
rem pad day and month with leading zeros
set _month=%_month:~-2%
set _day=%_day:~-2%
rem output format required is YYYYMMDD-XXX
md %_year%%_month%%_day%-LS
endlocal
I would like the date folder to be created on any UNC path where I do right click. I put a pause on my batch script and I could see the UNC path not supported message.