• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

How To "Null" Files

NinjaNife

New Member
Joined
Oct 15, 2009
Messages
172 (0.03/day)
Location
Kentucky, USA
System Name Custom
Processor Intel i7-875K 2.9GHz (OC'd to 4.0GHz)
Motherboard MSI P55-GD80
Cooling Sidewinder Custom MCP655 / Watercool HEATKILLER® CPU Rev3.0 1156 LT / Swiftech MCR320-QP / XSPC Dual
Memory G.SKILL PiS 2000MHz 8GB 6-9-6-24
Video Card(s) EVGA GTX 470 1280MB Superclocked+ 750/1500/1750
Storage Western Digital Black x2 1TB RAID-0, Seagate Barracuda 1TB, Western Digital 500GB
Display(s) ASUS VH242H 24" 1080p
Case Cooler Master HAF 932
Audio Device(s) Creative X-FI Titnium Fatal1ty Champion Series
Power Supply Corsair Professional Series AX1200 1200W
Software Windows 7 Ultimate nVidia Edition 64bit
If this is in the wrong section please move it.

I am not sure if I am using the correct term, but I am trying to find either a batch file or another program that will "null" a file's contents.. Basically I am trying to do is strip the contents of a file but leave the shell.

An example of this is with Call of Duty 4 server files; you have "iw_02.iwd" which contains information used by the game for Singleplayer, and I want to "null" it (leaves all files inside intact since the game requires them to be there (even empty), but basically strips the content in order to save space).. I don't know if this is making sense or not lol. Below are is an example of what I mean.

CoDFileExample.jpg

On the left is the original, and on the right is the "nulled" version. Other iwd files contain .wav audio, and when you try to play the "nulled" versions, Windows Media Player starts and ends (it is recognized as a good file but no content I guess). I am attempting to recreate what was done here (no idea who made this though). Any ideas? Thanks.

Brendan "NinjaNife" West
 
When you delete a file, it makes the space accessible to other applications. It won't necessarily overwrite it right away but it could.

An empty container file is pointless (like what is in your pic).


Are you trying to make a game rip (videos/audio removed)?
 
When you delete a file, it makes the space accessible to other applications. It won't necessarily overwrite it right away but it could.

An empty container file is pointless (like what is in your pic).


Are you trying to make a game rip (videos/audio removed)?

What is in the pic is what I am trying to do (pointless yes but that's what I am wanting to learn). Not sure if it could be called a rip..well, it could be...I am making a dedicated server and removing all client files (which are the iwd files). From what I have been told, the game will sometimes look for those files (even if they are just containers) to see if anything is missing, which is why the ones in my pic were made in the first place. Do you know how to make them into "empty containers"? Thanks for the reply.

Brendan "NinjaNife" West

*EDIT*
Upon further review of the example file I have found that only the audio/video/image files have been nulled (file extensions .wav, .wmv and .iwi), while the other file types have been left (they are needed for the server to run). So I guess I am looking for something that only nulls filetypes that I specify..not sure if that makes it harder or not lol. Thanks again for the help.
 
Last edited:
I'd just copy and rename those 40 byte files. They are likely empty containers already.

In a batch file, it would be something like:
Code:
FOR %%a IN (dir *.iwd ) DO copy empty.iwd %%a
 
I'd just copy and rename those 40 byte files. They are likely empty containers already.

In a batch file, it would be something like:
Code:
FOR %%a IN (dir *.iwd ) DO copy empty.iwd %%a

Would that change the names of the original iwd files? Or the names of the empty shells?

I mean, would it work to just take a single file (a container I would name "test.iwd") and replace all of the other files with that one (but keeping the same names, so "test.iwd" would be renamed to "$black.iwi" when it replaces the original "$black.iwi" file). Would that be easier? If so, how do I do a mass replace/rename of files (I know how to replace files with specific names but have never done anything like this lol). Thanks.

Brendan "NinjaNife" West
 
Last edited:
dir *.iwd should return a list of each iwd file in the directory it runs in. e.g.

C:\abc.iwd
C:\bcde.iwd
C:\03nscv.iwd

%%a is a variable that should have the above line.

copy command copies the source (empty.iwd) to the destination (what is contained in %%a).


empty.iwd should really be outside of the directory the batch is in so it doesn't attempt to read/write itself. Change it to "C:\empty.iwd" or something similar.

Code:
FOR %%a IN (dir *.iwd) DO copy /B /Y "C:\empty.iwd" %%a
 
Success! After I failed multiple times by typing "iwd" where there should have been "iwi", it works! Thanks for the help :D

Brendan "NinjaNife" West

P.S.
Is there any way for it to search all subfolders as well?
 
Last edited:

I tried that but it said the syntax is incorrect. Here is what I used:

Code:
FOR %%a IN (dir /S *.iwi) DO copy /B /Y "D:\pRo Servers\New folder\New folder (2)\empty.iwi" %%a
PAUSE

Here is the error:

Code:
D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New folder (2)\empty.iwi" /S
The syntax of the command is incorrect.

D:\pRo Servers\New folder\New folder>PAUSE
Press any key to continue . . .

Any ideas?


Brendan "NinjaNife" West
 
All you changed was the /S?
 
Last edited:
All you changed was the /S?

From the code I used before yes. I put "/S" like you said and got the syntax error. Remove it and the batch file works, but only modifies files within the same folder.

Brendan "NinjaNife" West
 
Try this:
Code:
FOR /F "usebackq" %%a IN (`dir /S *.iwi`) DO copy /B /Y "D:\pRo Servers\New folder\New folder (2)\empty.iwi" %%a

That should theoretically force dir /S *.iwi to be treated as a command instead of a string.
 
Try this:
Code:
FOR /F "usebackq" %%a IN (`dir /S *.iwi`) DO copy /B /Y "D:\pRo Servers\New folder\New folder (2)\empty.iwi" %%a

That should theoretically force dir /S *.iwi to be treated as a command instead of a string.

I didn't get that error this time, but it still doesn't work :( It just copied all kinds of strange files into the first directory (where the batch file is). Here is the code:

Code:
D:\pRo Servers\New folder\New folder>FOR /F "usebackq" %a IN (`dir /S *.iwi`) DO
 copy /B /Y "D:\pRo Servers\New folder\New folder (2)\empty.iwi" %a

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" Volume
        1 file(s) copied.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" Volume
        1 file(s) copied.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" Directory
        1 file(s) copied.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" 10/12/2009
The syntax of the command is incorrect.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" 10/12/2009
The syntax of the command is incorrect.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" 10/12/2009
The syntax of the command is incorrect.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" 10/12/2009
The syntax of the command is incorrect.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" 10/12/2009
The syntax of the command is incorrect.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" 10/12/2009
The syntax of the command is incorrect.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" 10/12/2009
The syntax of the command is incorrect.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" 10/12/2009
The syntax of the command is incorrect.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" 8
        1 file(s) copied.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" Total
        1 file(s) copied.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" 8
        1 file(s) copied.

D:\pRo Servers\New folder\New folder>copy /B /Y "D:\pRo Servers\New folder\New f
older (2)\empty.iwi" 0
        1 file(s) copied.

D:\pRo Servers\New folder\New folder>PAUSE
Press any key to continue . . .

Sorry for being so much trouble lol. Thanks for the help.

Brendan "NinjaNife" West
 
Code:
FOR /F %%a IN ('dir /S *.iwi') DO copy /B /Y "D:\pRo Servers\New folder\New folder (2)\empty.iwi" %%a
 
Code:
FOR /F %%a IN ('dir /S *.iwi') DO copy /B /Y "D:\pRo Servers\New folder\New folder (2)\empty.iwi" %%a

Same result as before (just those random files added into the root folder). Here are the names of the newly created files: "0", "8", "Directory", "Total" and Volume".

Brendan "NinjaNife" West

*EDIT*
I found another batch file that I had gotten a few months ago and made some changes (merged it with yours) and it seems to work properly. Here is the code:

Code:
for /F "tokens=*" %%P in ('dir /b /s *.iwi') do copy /Y .\empty.iwi "%%P"
PAUSE
As far as I can tell that is doing what I wanted (or just replacing the insides of the file, no clue really lol). What do you think?
 
Last edited:
It might be the /B but could also be the tokens=*. It works, that's all that matters.
 
It might be the /B but could also be the tokens=*. It works, that's all that matters.

I guess so lol. Sorry it took so long. Thanks for your help!


Brendan "NinjaNife" West
 
Back
Top