Recently installed a new Windows 2012 Essentials server for a client. They had a very old XP system they had been using as a file server. Several weeks after what appeared to be a successful migration of the clients files from the old XP system, the client has discovered several 0KB files.

I have searched their file structure and there are thousands of these.

Good news is I have the original disks still and the files are present and usable on this disk. I have it as a image.vhd and attached to the server as a drive.

Bad news is the client has used and updated several files from the data migration and so a whole-sale re-export of the data is not possible. Or even if I did do one and manually watched for replacing the 0KB one, the time involved is not practical due to the number of files involved.

This is my first time I have had to deal with this kind of issue and I am at a loss as to the best way to approach this.

I know I need to somehow search for the client data files with a 0KB Size and then when one is found look on the original disk for the file and copy and replace the 0KB file on the server with the one found on the original disk.

I do code, but not in Windows. My coding experience is PHP, HTML, CSS, Javascript and other languages around websites and databases.

I could really use some help on how I should approach this.

Thanks in advance!

  • Do you mean zero size (in bytes) by 0KB? The same or alike folder structure? Robocopy could be useful for you. – JosefZ Mar 27 '15 at 22:04
  • The filesize shows as 0 KB in windows explorer. The files appear in various places across the file structure, not in any one folder. The file structure between the current server files and the original system image would be alike. I have a screen shot sample, but not enough reputation on this board to post it yet.... – BitBug Mar 27 '15 at 22:14

Next script could be a starting point.

@SETLOCAL enableextensions disabledelayedexpansion

set "serverPath=D:\Path\files"
set "backupPath=D:\bat\files"

for /R "%serverPath%\" %%G in (*.*) do (
    if %%~zG EQU 0 (
        for /R "%backupPath%\" %%g in ("*%%~nxG") do (
            if "%%~nxG"=="%%~nxg" (
                echo server %%~G %%~zG 
                echo backup %%~g %%~zg

goto :eof

Reference for basic documentation:

Note (with direct links):

Sample output. Made some subfolders, each cca 20 files, in two of them some zero sized (in bytes) files (wrong copy simulated):

server D:\Path\files\folder 1\111070290_8 daftar isi.pdf 0
backup D:\bat\files\folder 1\111070290_8 daftar isi.pdf 29
server D:\Path\files\folder 1\111070290_9_daftar_gambar.pdf 0
backup D:\bat\files\folder 1\111070290_9_daftar_gambar.pdf 32
server D:\Path\files\folder 2\111070117_2_lembar_pernyataan_orisinalitas.pdf 0
backup D:\bat\files\folder 2\111070117_2_lembar_pernyataan_orisinalitas.pdf 49
server D:\Path\files\folder 2\111070117_3_lembar_pengesahan.pdf 0
backup D:\bat\files\folder 2\111070117_3_lembar_pengesahan.pdf 36
  • Thanks JosefZ! That put me on the path to success. Greatly appreciate it! – BitBug Apr 8 '15 at 23:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.