Color empty files in Windows

5

1

I face a need to show empty (0 bytes size) files in color in Windows Explorer. (I get them over sftp and need to know whether they're empty to prevent data loss - an application creates empty files and then fills them in; I keep transferring empty files and deleting them from server afterwards, when they're no longer empty). A web search seems fruitless.

You can color compressed and encrypted files on an NTFS volume, so it would be nice if there were a way to color 0-byte files as well.

Screenshot of Explorer with colored compressed and encrypted files

Solutions for Windows File Explorer, other explorers, Powershell are accepted.

user89272

Posted 2013-12-04T05:00:14.750

Reputation:

I’m afraid that you may have wasted your bounty. There doesn’t appear to be any existing solution for this. Someone else asked this, but ended up nowhere. Another person asked about implementing such a feature, but also ended up nowhere. The closest thing to a solution is to use XYplorer which supports this.

– Synetech – 2013-12-09T01:04:54.220

@Synetech That's okay, I never wear more than 100 points comfortably. Thanks for the additional advice, I will try it. You may want to also include it as an answer; I have edited question title to permit additional Explorer softwares. – None – 2013-12-09T01:14:50.410

Ah, well if you can use an alternative, then there are more solutions. However, be aware that XYplorer for one is not free. (I’ll check if some of the other shells support file-coloring.) – Synetech – 2013-12-09T01:20:40.790

I’ve got a a great answer coming… –‿⊙ – Synetech – 2013-12-09T01:53:06.773

1If you keep changing the goal posts (like asking for more solutions across a wider range of apps) then it's by definition a question too broad – random – 2013-12-10T17:09:09.867

If your requirement is to detect empty files, why stick to the color-requirement? Look at your folders in detail view and sort them by file size. – Jan Doggen – 2013-12-13T14:44:17.487

@JanDoggen, how exactly would they sort folders by size? There’s no FolderSize column in Windows, and from Vista, they removed the ability for shell-extensions like Folder Size from working anymore. Besides, that wouldn’t help anyway if there are empty files and non-empty files in the same folder. – Synetech – 2013-12-13T17:02:52.990

@Synetech The OP wants to mark empty files, yet he displays files and folders, one of them colored??? I have a size column in my XP Explorer here, which indeed does not show folder size. But I must confess I 'live' in Total Commander, not in Explorer. – Jan Doggen – 2013-12-13T18:16:04.297

@JanDoggen, re-read the question carefully, even from the start, she is not asking about empty folders, she is asking about empty files. That is, files that have a size of 0 bytes.

– Synetech – 2013-12-13T18:34:09.580

Answers

10

Unfortunately there don’t seem to be any existing shell-extensions for Explorer to control the colors of files and folders.

If you are open to using alternate shells, then there are a several options:

  • XYplorer supports coloring files (figure 1), but currently only by name. However, they take feature-requests, so you could ask them to implement a size-based color filter. Unfortunately XYplorer is not free.

  • Q-Dir supports file-coloring as well (figure 2), but it too only supports filtering by name (as well as for read-only files). It too takes feature requests. Plus, Q-Dir is free.

  • Directory Opus supports file-coloring (figure 3) according to any property of the file, but it’s not free. Plus, it’s not clear whether you can specify trigger values for those file properties. (It looks like you can only color columns.) Of course if they it doesn’t, then you can request the feature.

  • Far Manager is a free console file manager (like the command-prompt) which means it is text-based. If that is acceptable, then it has exactly what you want. You can create a color-filter via F9OptionsFiles highlighting and sort groups to highlight zero-byte files (figure 4).

  • Multi Commander is free as well. They too take feature-requests, but that’s not necessary because it already supports file-coloring (as of 3.5) according to several factors (figure 5). In fact, Multi Commander already comes with a color-filter rule for empty files built-in!


Figure 1: XYplorer’s color-filter editor (only accepts filename patterns)

Screenshot of XYplorer’s color-filter editor

Figure 2: Q-Dir’s file-coloring (only by file-name and read-only attribute)

Screenshot of Q-Dir with file-coloring

Figure 3: Directory Opus has limited file-coloring

Screenshot of Directory Opus’s file-coloring

Figure 4: Far Manager with zero-byte files colored

Screenshot of Far Manager with zero-byte files colored

Figure 5: Multi Commander with zero-byte files colored

Screenshot of Multi Commander with zero-byte files colored

Synetech

Posted 2013-12-04T05:00:14.750

Reputation: 63 242

(Sorry it took so long. I did this up last night, but the auto-save function wasn’t work, so I copied it to a text file while I was working, but then accidentally deleted it. It was too late to start over, so I had to re-do it all from scratch today.) – Synetech – 2013-12-09T17:48:05.633

Perfect. Inspired by your answer I added a powershell tag; solutions involving coloured directory listing of powershell are welcome. – None – 2013-12-09T22:12:02.353

Well it’s certainly possible, but it’s a lot more involved. Fopedush’s answer includes some code to colorize based on size.

– Synetech – 2013-12-10T22:09:34.220

1

  • For Empty Folders:

    You can runs this batch file in the current directory to mark the folders which are empty with a different icon (desktop.ini must be in the same directory as the batch-file)

    :: empty_folders.bat
    @echo off
    dir /a /b %1 2>nul | findstr "^" >nul || echo %%~fA
    for /f "eol=: delims=" %%A in ('dir /s /ad /b %1') do (
      dir /a /b "%%~fA" 2>nul | findstr "^" >nul || call:copyini %%~fA
    )
    goto :eof
    
    :copyini 
      copy %~dp0desktop.ini %1%
      attrib +s +h +a  %1%\desktop.ini
    

     

    ; desktop.ini 
    [.ShellClassInfo]
    IconResource=C:\WINDOWS\system32\SHELL32.dll,234
    [ViewState]
    Mode=
    Vid=
    FolderType=Generic
    
  • For Empty Files:

    You can use a tool like the FMS Empty File Remover to simplify removing empty files.

N.B.: Both of these must periodically be manually run to update; they don’t automatically detect empty files and folders.

ukanth

Posted 2013-12-04T05:00:14.750

Reputation: 9 930

2Clever work-around. It can even be adapted for empty files as well. Too bad it must be manually re-run every now and then to update, unlike how compressed or encrypted files can be colored automatically. – Synetech – 2013-12-05T07:31:32.473

Thanks; please also note that the question now has wider scope, not just Windows File explorer. – None – 2013-12-11T03:05:03.477

1

I'm pretty sure there's no way to render files with 0 bytes size in different color in File Explorer, unless you implement a custom IShellView.

Yet you can use search to find files with size of 0: Enter

size:=0

into Search field in File Explorer. The view will display all files with zero size: Search for files with 0 bytes size in File Explorer


If you use Far Manager, you can highlight such files:

  1. Press F9 to show the menu bar.
  2. Click Options and then click Files highlighting and sort groups.
  3. While cursor is in the first group (above Upper sort group), press Ins to add new highlighting rule:
    1. Select Mask checkbox, and put * in the Mask edit box.
    2. Select Size checkbox, and 0 into both >= and <= edit boxes.
      Far Manager: Files highlighting rule for size=0
    3. Click 1. Normal file name to change display color, click the desired Foreground and Background.
    4. Click 3. Selected file name, 5. File name under cursor, 7. File name selected under cursor to adjust these colors.
    5. Click OK to save the highlighting rule.
  4. Press Esc or click outside the Files highlighting dialog to close it.

The files with zero size will be highlighted.
Highlight rules are processed in the order they are displayed in the Files highlighting dialog, to move a rule up or down, select the rule with cursor and press Ctrl+ or Ctrl+ correspondingly.

Alexey Ivanov

Posted 2013-12-04T05:00:14.750

Reputation: 3 900

Thanks; please also note that the question now has wider scope, not just Windows File explorer. – None – 2013-12-11T03:04:47.790

@Svetlana Yes, I saw that. I mentioned Far Manager, it's the only other file manager than File Explorer that I use. And I have nothing to add to Synetech's answer.

– Alexey Ivanov – 2013-12-11T07:22:24.930

0

The DIY answer is to write a custom DLL and inject that into the shell. Once hooked it would alter the file color every time the shell is refreshed. Either that or a kernel mode driver.

If someone were to go that far, they might as also add some registry reading magic to their DLL that allows for toggling from Folder Options > View > Advanced Settings like a real shell extension.

Knuckle-Dragger

Posted 2013-12-04T05:00:14.750

Reputation: 1 817

That would be ideal, but it can be assumed that it must be difficult to actually do, otherwise someone would have done it by now. For example, Folder Size was a great extension for XP which countless people loved, but Microsoft made it literally impossible in Vista and up (okay, maybe not literally, but removing extension support made it difficult enough that it’s not worth the effort now because getting it to work would require hacking Windows). This is the same thing; in Vista+, Explorer no longer uses a simple listview control, it uses a proprietary DirectUIHWND control. – Synetech – 2013-12-13T17:00:27.890

Difficult, but far from implausible. Someone with C or C++ and 30 hours of free-time could theoretically find a 'hello world' driver sample, google SetWindowsHookEx and using the SDK debugging tools 'Debug' shell32.dll (or Hack if you prefer) for the entry point. True it's easier said than done, but the documentation is available if one knows where to look, usually MSDN or Stack Overflow. – Knuckle-Dragger – 2013-12-13T17:45:34.167

1

You’re missing the point; it would actually be pretty simple if Explorer still used a standard listview control; the methods for manipulating, colorizing, etc. those are old and well known. But in Vista+, they switched to a DirectUIHWND, which isn’t documented [1] [2] [3] [4].

– Synetech – 2013-12-13T18:03:51.997