REALLY need some help! Been trying tirelessly for weeks...
This script will change the attributes of all sub-directories then using the icon located within \Icon of sub-directories will create a relevant Desktop.ini that changes the folder icon and a few other settings (If there is an icon located within \Icon)
@ECHO OFF
CHCP 1252 >NUL
set ICOINI=Desktop.ini
for /D %%d IN (*) do (
set "FOLDER=%%d"
call :write_File FOLDER
)
Pause
:Write_File
setlocal EnableDelayedExpansion
IF NOT EXIST "!FOLDER!\Icon\*.ico" goto :EOF
attrib +a +s "!FOLDER!" /d /s
for %%F in ("!FOLDER!\Icon\*.ico") do (set "ICO=%%~nxF")
IF EXIST "!FOLDER!\%ICOINI%" attrib -a -s -h "!FOLDER!\%ICOINI%"
(
echo [.ShellClassInfo]
echo IconResource=!CD:~2!\!FOLDER!\Icon\!ICO!, 0
echo IconFile=!CD:~2!\!Folder!\Icon\!ICO!
echo IconIndex=0
echo InfoTip=!ICO:~0,-4!
echo.
echo FolderType=Videos
echo DefaultDropEffect=4
echo ConfirmFileOp=1
)>"!FOLDER!\%ICOINI%"
attrib -a +s +h "!FOLDER!\%ICOINI%"
echo !FOLDER!
endlocal
goto :EOF
exit /b
The script works in that it changes the attributes of relevant folders and creates Desktop.ini (Except if there is an exclamation mark!). Though it does not always change the icon of the folder. If I manually change Desktop.ini to "." and then back to Desktop.ini it instantly changes the folder icon. So is there a way of renaming Desktop.ini with attributes in tact?
My current method to resolve this problem was with something along these lines:
echo f | xcopy /Y /Q /H /R "!CD!\!FOLDER!\%ICOINI%" "!CD!\!FOLDER!\Desktoop.ini" /K
del /Q /AHS "!CD!\!FOLDER!\%ICOINI%"
echo f | xcopy /Y /Q /H /R "!CD!\!FOLDER!\Desktoop.ini" "!CD!\!FOLDER!\%ICOINI%" /K
del /Q /AHS "!CD!\!FOLDER!\Desktoop.ini"
This fails, sadly, but I don't know why. (It copies, deletes, copies, and then deletes just fine) just doesn't change the folders icon.
Okay, I have run into this problem numerous times before, and although some of it was to do with my command batch script, this problem does not appear to be. Although I would like some help coming up with a work around (If that is even possible in batch!).