Folders & Shortcuts Losing Custom Icons On Removable Flash Drive

TheDeerDude

New member
Power User
VIP
Local time
7:19 AM
Messages
204
Hello once more,

I've recently dedicated one of my USB flash drives to use as a drive with all the basic, necessary programs (N++, Unlocker, etc.) which I install on my computers after a fresh OS installation. So, to speed up the process of doing so, instead of having to download all the programs, I keep them on my USB flash drive.

I'm a rather organized person, and here's what my problemes are, using an example.
There's a removable flash drive with letter F:
On it, there is a folder called "Recuva".
Inside that folder, there is the installer, an icon, desktop.ini file and a shortcut (.url) to recuva's download page.

My initial issue was that when I changed the icon for the folder "Recuva", and plugged the drive in on another computer, the icon wasn't there. It's desktop.ini that causes it to not show, because it provides full path to the icon, with the drive letter that can be different on other computers. I have managed to overcome that issue by using "IconResource=\Recuva\recuva.ico" instead of "IconResource=F:\Recuva\recuva.ico" but it's a very time consuming process to have to change it manually for 60 folders. Is there any other solution to this?

I'm also having the same issue with my shortcuts (.url) files. Because of the same reason. I tried opening them with notepad (which surprisingly worked) but removing the drive letter only caused them to show a blank or default icon rather than the custom one.

I know it doesn't have any impact on usability. I can still install programs and open shortcuts from that flash drive, yet I'd like it to look neat.

Any help for this eye-candy-addict will be appreciated :p
 

My Computer My Computer

At a glance

Windows 7 x64
OS
Windows 7 x64
Do you keep normal installers to install on your desktop/laptop or portables so you can just run it from the USB stick. Either way if you customize the icons using icons on your desktop computer then as soon as you unplug the USB the icons will not work on another computer. Rather then have the desktop.ini if you already have the customized icon you need in each folder just right click the folder and choose Properties then Customize, Change Icon and point it to the icon in that folder and you can do the same for your URL shortcuts. As long as you have the icons you want on the USB drive itself it should stay the same. You can probably delete the Desktop.ini all together. Not sure if there's a way to do it all at once but maybe one of the gurus here will have a better ideas
 

My Computer My Computer

At a glance

Windows 7 Ultimate x64Q6600 3.1ghzKingston DDR2 6400 8GBGigabyte Radeon HD 6850 1GB 256-Bit
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Home Made
OS
Windows 7 Ultimate x64
CPU
Q6600 3.1ghz
Motherboard
Gigabyte GA-P35-DS3L
Memory
Kingston DDR2 6400 8GB
Graphics Card(s)
Gigabyte Radeon HD 6850 1GB 256-Bit
Sound Card
On board
Monitor(s) Displays
Acer X243H
Screen Resolution
1920x1080
Hard Drives
Intel 330 120GB SSD
WD 2TB 7200
PSU
Thermaltake Toughpower 750W Semi Modular
Case
Modified Alienware
Keyboard
A4Tech
Mouse
Gigabyte ECO600
Antivirus
Comodo
Browser
Cyberfox
I doubt that it matters, but I do keep installers as well as portables on the pendrive, here are some facts to clear things up:
Each installer has its own folder on in the main directory ("F:\" in my case)
Each of the folders contains an installer, an icon (.ico file) and a web shortcut (.url)
The icons I'm using to customize each folder are in each folder (Recuva's icon is in "F:\Recuva\")

And I did exactly what you've told me, to get to this point. As far as I know the "desktop.ini" is the configuration file for the folder its in, and it is necessary because it tells Windows Explorer to use a custom icon. Web shortcuts do not have such file because the location of their icons are within themselves.

The issue here is that different computers assign a different drive letter to my removable flash drive, causing all the icons not to work.

The fix that allows me to use custom icons for folders on the drive no matter what the drive letter is, is to remove the "F:" from desktop.ini file in each folder, and that isn't a problem, I was just wondering if there's a faster or easier way to do it rather than doing it manually. However, doing the same thing to my shortcuts (.url) doesn't work.

Either way, thank you for your reply, I appreciate it.
 

My Computer My Computer

At a glance

Windows 7 x64
OS
Windows 7 x64
Hi Viper,

Basically you're asking for a script to remove "F:" in the IconResource line in every desktop.ini that exists on your USB (F:\) drive.

So here it is:

[Revision1]
Code:
@echo off
setlocal EnableDelayedExpansion
REM Locate all desktop.ini\s in F:\ and replace instances of 
REM "F:" with "" in the IconResource line in each desktop.ini
:: don\'t change these
set tempfold=%TEMP%\%~n0
set tempfile=%TEMP%\%~n0\%~nx0.tmp
::
set desktop.ini=desktop.ini
set find=F:
set replace=
::
cd /d "%~d0"
if EXIST "%TEMPFILE%" ( del "%TEMPFILE%" )
if EXIST "%TEMPFOLD%" ( rd "%TEMPFOLD%" )
md "%TEMPFOLD%"
for /f "delims=" %%I in (' dir /s /a /b "%DESKTOP.INI%" ') do (
 copy NUL "!TEMPFILE!" >NUL
 echo.&echo ^<INPUT^>&echo.
 for %%X in ( %%I ) do ( set destpath=%%~dpX& set destpath=!DESTPATH:~0,-1!)
 attrib "%%I" -R -S -H
 for /f "tokens=1* delims=]" %%L in (' find /n /v "" ^<"%%~I" ') do (
  echo.%%M
  if "%%M" == "" ( echo.>>"!TEMPFILE!") else (
   set line=%%M
   if "!LINE:~0,12!" == "IconResource" (
    echo #TRUE >NUL
    set line=!LINE:%FIND%=%REPLACE%!
    echo !LINE!>>"!TEMPFILE!"
   ) else (
    echo !LINE!>>"!TEMPFILE!"
   )
  )
 )
echo.&echo ^</INPUT^>&echo.
rename "!TEMPFILE!" "%DESKTOP.INI%"
set tempfile=%TEMP%\%~n0\%DESKTOP.INI%
replace "!TEMPFILE!" "!DESTPATH!" /r
echo.&echo ^<OUTPUT^>&echo.
type "!TEMPFILE!"
echo.&echo ^<OUTPUT^>&echo.
attrib "!DESTPATH!\%DESKTOP.INI%" +S +H
if EXIST "!TEMPFILE!" ( del "!TEMPFILE!" )
)
if EXIST "!TEMPFOLD!" ( rd "!TEMPFOLD!" )
goto :eof
Simply place the batch script anywhere on your USB and run.

Note: File attributes will not be preserved. All desktop.ini\s will be changed to a System Hidden file.



Edit: The script in this thread is depreciated. Please see http://www.sevenforums.com/general-...t-wriring-help-attn-pyprohly.html#post3072384 for a better version.
 

Attachments

Last edited:

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
@Pyprohly:
Now, that is truly wonderful! Thank you so much. That'll come in handy, definitely. It completely solves my first problem with the folders' icons. I'll be keeping that, and using it regularly. It'll save me a lot of time ;).

Once I figure out what should go in each shortcut (.url) in order for it to display its set icon (removing "F:" doesn't do the trick for .urls unfortunately) then I'll be able to modify your script and use it for that purpose too, again, thank you for saving me so much time.
 

My Computer My Computer

At a glance

Windows 7 x64
OS
Windows 7 x64
Most Welcome.

I've revised and fixed up a few lines in the script; mostly just indentation adjustments for readability and also lines that should have been removed that were used for debugging purposes. (appologies about 'desk.txt'; glad you got it to work despite my mistake .)

When doing a repetitive task on a computer 'by hand', know that there is probably a better way of accomplishing it.
 

My Computer My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Thank you, it is indeed easier to understand now. I did some programming in batch a while ago, and while I don't quite understand what some of parts of your code do, it was obvious to spot the little mistake. That's what I was seeking - an easy way to do a repetitive task, again, thank you.

I shall continue to try to get the shortcuts (.url) to keep their custom icons if the drive's letter changes. So far - no luck.
 

My Computer My Computer

At a glance

Windows 7 x64
OS
Windows 7 x64
i'm 100% sure you wouldn't see this but did you find a way to fix the desktop.ini files
tried the one Prophly posted but couldn't make it work because i only have C:/ and the folders i wanna fix are on desktop\new folder
 

My Computer My Computer

At a glance

Win 7
Computer type
PC/Desktop
OS
Win 7
C:\Users\Sony\Desktop\New folder\
this is the line i need to delete
i hope you see this : (
 

My Computer My Computer

At a glance

Win 7
Computer type
PC/Desktop
OS
Win 7
Back
Top