@echo off
setlocal enabledelayedexpansion
rem 批量文件夹图标 by hui-Zz @2017.02.07 hui0.0713@gmail.com
rem 请先定位盘符,ProgramList路径须为同一盘符,过多可分行写入ProgramList.txt中,调换注释for循环
D:
rem set ProgramList="D:\Program Files (x86)" "D:\Program Files"
for /f "delims=" %%t in (ProgramList.txt) do (
rem for %%t in (%ProgramList%) do (
cd %%t
for /d %%i in (*) do (
if not exist "%%i\desktop.ini" (
if exist "%%i\%%i.exe" (
echo %%i\%%i.exe
(echo [.ShellClassInfo]
echo IconResource=%%i.exe^,0
)>>"%%i\desktop.ini" && attrib +r "%%i" && attrib +s +h "%%i\desktop.ini"
) else (
set icoz=
for /f "delims=" %%j in ('dir/b/a "%%i\*.ico" 2^>nul^|find /i ".ico"') do (set icoz=%%j)
if defined icoz (
echo %%i\!icoz!
(echo [.ShellClassInfo]
echo IconResource=!icoz!^,0
)>>"%%i\desktop.ini" && attrib +r "%%i" && attrib +s +h "%%i\desktop.ini" && attrib +h "%%i\!icoz!"
) else (
set exez=
for /f "delims=" %%j in ('dir/b/a "%%i\*.exe" 2^>nul^|find /i ".exe"') do (set exez=%%j)
if defined exez (
echo %%i\!exez!
(echo [.ShellClassInfo]
echo IconResource=!exez!^,0
)>>"%%i\desktop.ini" && attrib +r "%%i" && attrib +s +h "%%i\desktop.ini"
)
)
)
)
)
echo.
echo %%t [Generate the folder icon complete]
echo =============================================
)
echo.
pause