Folders & Shortcuts Losing Custom Icons On Removable Flash Drive


  1. Posts : 206
    Windows 7 x64
       #1

    Folders & Shortcuts Losing Custom Icons On Removable Flash Drive


    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
      My Computer


  2. Posts : 758
    Windows 7 Ultimate x64
       #2

    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


  3. Posts : 206
    Windows 7 x64
    Thread Starter
       #3

    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


  4. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #4

    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 Script wriring help (Attn: Pyprohly) for a better version.
    Folders &amp; Shortcuts Losing Custom Icons On Removable Flash Drive Attached Files
    Last edited by Pyprohly; 24 May 2015 at 07:08. Reason: Linked to thread with updated script. Thanks PepFontana.
      My Computer


  5. Posts : 206
    Windows 7 x64
    Thread Starter
       #5

    @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


  6. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #6

    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


  7. Posts : 206
    Windows 7 x64
    Thread Starter
       #7

    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


  8. Posts : 2
    Win 7
       #8

    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


  9. Posts : 2
    Win 7
       #9

    C:\Users\Sony\Desktop\New folder\
    this is the line i need to delete
    i hope you see this : (
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 10:28.
Find Us