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
  • 28,064
Chronia
  • 21

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
)
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" }