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!
Best Answer
Next script could be a starting point.
Reference for basic documentation:
Note (with direct links):
set
command: parentheses inset "serverPath=D:\Path\files"
etc. to avoid undesired leading or trailing blank spaces in a variable name and valueFOR /R
Loop through files (Recurse subfolders); look out for parameter names%%G
and%%g
are case sensitive~
Parameter Extensions (modifiers)SETLOCAL
commandif
,for
etc.)Sample output. Made some subfolders, each cca 20 files, in two of them some zero sized (in bytes) files (wrong copy simulated):