revisiting this months later...
for custom icons through all sub-directories shown on a the folder tab...
this may not be practical for everyone's use case or folder structure depending on the area your doing this.... BUT...
i made a AutoHotkey script that, when supplied a root\starting folder & an icon file, will create a desktop.ini
for every sub-folder so they all have the some icon.
If anyone using AHK you can assign a hotkey to this snippet of code in your ahk script. which is what you see in the screen recording.
CAUTION NOTES...
I've only tested this with .ico
files, use caution if your wanting to set an icon from a .dll
or .exe
. It should work thou the default icon # will be set to ,0
, e.g. the very first icon in the file.
also...
Any existing desktop.ini
files below the chosen folder will be erased before setting the custom icon. e.g. If you have set other custom options to that folders .ini
via windows, such as view states, they will be reset.
setfoldericonsinallsubs:
; rootFolder := "C:\Users\CLOUDEN\test 1" ; Change this to your desired root folder
; iconPath := "C:\xsysicons\vs code icons ico\check white file_type_light_testcafe_32x32.ico" ; Change this to your desired icon file
FileSelectFolder, rootFolder, *c:\Users\%a_username%,6,Select A Folder
if !FileExist(rootfolder)
{
tooltip, ERR! @ Line: %A_LineNumber% -- %A_scriptname%`n`nFolder Doesn't Exist! Opration Canceled.
sleep 1500
tooltip
return
}
FileSelectFile, iconpath, 1, *%A_MyDocuments%, Select a Icon,
if ErrorLevel
{
;; todo, expand error check for acceptable icon types.
tooltip, ERR! @ Line: %A_LineNumber% -- %A_scriptname%`n`nA Icon File Must Be Selected! Operation Canceled.
sleep 1500
tooltip
return
}
SetFolderIcons(rootFolder, iconPath)
; Re-Start Windows Explorer to apply changes
RunWait, ie4uinit.exe -show
RunWait, taskkill /F /IM explorer.exe
sleep 1000
Run, explorer.exe
return
SetFolderIcons(folder, icon) {
iniFile := folder "\desktop.ini"
; Write desktop.ini with icon settings
FileDelete, %iniFile% ; Ensure clean overwrite
FileAppend,
(
[.ShellClassInfo]
IconResource=%icon%,0
), %iniFile%
; Make folder read-only and desktop.ini hidden/system
FileSetAttrib, +R, %folder%
FileSetAttrib, +SH, %iniFile%
; Loop through all subfolders
Loop, %folder%\*, 2
SetFolderIcons(A_LoopFileFullPath, icon)
}