How can i make a .bat file that automatically changes the icon of a folder to the icon present in the current directory ie - "transprent.ico" ?
3 Answers 3
You can do this changing Desktop.ini file
@echo off
set /p "fld=Folder: "
set /p "ico=Icon file: "
md "%fld%\icons" 2>nul
if exist %ico% copy "%ico%" "%fld%\icons\icon.ico" /y 1>nul
attrib -h -s "%fld%\desktop.ini" 2>nul
(
echo/[.ShellClassInfo]
echo/IconResource=icons\icon.ico,0
) > "%fld%\Desktop.ini"
attrib +h +s -a "%fld%\Desktop.ini"
attrib +r "%fld%"
attrib +h "%fld%\icons"
taskkill -im explorer.exe /f >nul&start explorer
Comments
I have this batch file I created. Put it in the parent folder of all the folders that you want to search through. This version looks for a PNG with a matching name to the ICO file but you can edit that part to make it only do an ICO file it finds, if you like. It will make a copy of your old desktop.ini file as well but that is also you can edit optionally.
@echo off
set O=desktop.old
set F=desktop.ini
FOR /R %%I IN (*.ico) DO @(
cd%%~pI
if exist %%~dpnI.png (
echo %%~dpnI.png
attrib -h -s %F%
copy /Y %F% %O%
echo [.ShellClassInfo] > %F%
echo IconResource=%%~nxI,0 >> %F%
echo [ViewState] >> %F%
echo Mode= >> %F%
echo Vid= >> %F%
echo FolderType=Videos >> %F%
echo Logo=%%~nI.png >> %F%
attrib +h +s %F%
)
)
cd ..
Comments
I know this is not the exact solution you look for but, still is a workaround
1.install theinpaint/FolderIco
2.add the path of FolderIco.exe to your environment path
3.create your batch file as follows :
FolderIco -f "[path to your directory]" --icon "path to your .ico file"