2

I found ArtOfWarfare's script on this thread Windows 7 - display date using small icons

I think it's great however it's missing one thing, the year. Is there anyway to add the year to the script and have it display DayofWeek, Month, Day, year? It doesn't work to simply add %year% after %day% of this line of code: ren *.lnk "%dayofweek%, %month% %day% .lnk"

Would love to get this toolbar/script running on my pc, just would really like the year displayed too. Appreciate any help!

fixer1234
  • 27,064
  • 61
  • 75
  • 116
Chronia
  • 21
  • 1

2 Answers2

0

This edit to the ArtofWarefare script adds the year. The toolbar width may have to be expanded (by unlocking the task bar) to accommodate all of the parameters.

echo off
setlocal enabledelayedexpansion
cd /d "%~dp0\Date"
call :getShortDate
ren *.lnk "%dayofweek% %month% %day%, %year%  .lnk"
exit /b

:getShortDate
for /f "skip=1 tokens=1-4" %%A in ('wmic path Win32_LocalTime get day^,dayofweek^,month^, year /value /format:table') do (
    set day=%%A

    if "%%B"=="0" set dayofweek="Sun"
    if "%%B"=="1" set dayofweek="Mon"
    if "%%B"=="2" set dayofweek="Tue"
    if "%%B"=="3" set dayofweek="Wed"
    if "%%B"=="4" set dayofweek="Thu"
    if "%%B"=="5" set dayofweek="Fri"
    if "%%B"=="6" set dayofweek="Sat"
    if "%%B"=="7" set dayofweek="Sun"

    if "%%C"=="1"  set month="Jan"
    if "%%C"=="2"  set month="Feb"
    if "%%C"=="3"  set month="Mar"
    if "%%C"=="4"  set month="Apr"
    if "%%C"=="5"  set month="May"
    if "%%C"=="6"  set month="Jun"
    if "%%C"=="7"  set month="Jul"
    if "%%C"=="8"  set month="Aug"
    if "%%C"=="9"  set month="Sep"
    if "%%C"=="10" set month="Oct"
    if "%%C"=="11" set month="Nov"
    if "%%C"=="12" set month="Dec"

    set year=%%D

    exit /b
)
Sathyajith Bhat
  • 61,504
  • 38
  • 179
  • 264
Rob Stavis
  • 11
  • 1
0

Here's the original code I saw on the page you linked:

@echo off
setlocal enabledelayedexpansion
cd /d "%~dp0\Date"
call :getShortDate
ren *.lnk %month%-%day%.lnk
exit /b

:getShortDate
for /f "skip=1 tokens=1-3" %%A in ('wmic path Win32_LocalTime get day^,month^,year /value /format:table') do (
set day=00%%A
set day=!day:~-2!
set month=00%%B
set month=!month:~-2!
set year=%%C
set year=!year:~-2!
exit /b
)

from this post, posted by and31415, edited by ArtofWarfare.

Add the year variable (already established in the batch file :getShortDate function) into the rename statement.

ren *.lnk %month% %day% %year% .lnk"

Also:

Powershell version (this replaces the whole batch file, OR you enter this as a scriptblock in a scheduled task, or use Powershell Jobs to schedule it as a job):

cd <path  to link>; gci *.lnk | % { rename $_ "$(get-date -f "MM dd yy") .lnk" }
Jeter-work
  • 523
  • 2
  • 9
  • No Idea what power shell is, however, as I mentioned previously, simply adding %year& to that link of code doesn't work. My husband says there is a variable missing for year that needs to be created. Please be sure you are looking at the second batch script on that link written by ArtofWarefare, not the first batch script which displays the month numerically and not the name of the month, nor does it display the day of the week, which is why I am using ArtofWarfare's batch script, but as mentioned it is missing the year. – Chronia Nov 08 '15 at 01:44