# How To "Null" Files



## NinjaNife (Aug 23, 2011)

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.






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


----------



## FordGT90Concept (Aug 23, 2011)

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)?


----------



## NinjaNife (Aug 23, 2011)

FordGT90Concept said:


> 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).
> 
> ...



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.


----------



## FordGT90Concept (Aug 23, 2011)

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:

```
FOR %%a IN (dir *.iwd ) DO copy empty.iwd %%a
```


----------



## NinjaNife (Aug 23, 2011)

FordGT90Concept said:


> 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:
> 
> ...



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


----------



## FordGT90Concept (Aug 23, 2011)

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.


```
FOR %%a IN (dir *.iwd) DO copy /B /Y "C:\empty.iwd" %%a
```


----------



## NinjaNife (Aug 23, 2011)

Success!  After I failed multiple times by typing "iwd" where there should have been "iwi", it works!  Thanks for the help 

Brendan "NinjaNife" West

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


----------



## FordGT90Concept (Aug 23, 2011)

http://www.computerhope.com/dirhlp.htm

dir /S *.iwi


----------



## NinjaNife (Aug 23, 2011)

FordGT90Concept said:


> http://www.computerhope.com/dirhlp.htm
> 
> dir /S *.iwi



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


```
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:


```
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


----------



## FordGT90Concept (Aug 23, 2011)

All you changed was the /S?


----------



## NinjaNife (Aug 23, 2011)

FordGT90Concept said:


> 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


----------



## FordGT90Concept (Aug 23, 2011)

Try this:

```
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.


----------



## NinjaNife (Aug 24, 2011)

FordGT90Concept said:


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



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:


```
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


----------



## FordGT90Concept (Aug 24, 2011)

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


----------



## NinjaNife (Aug 24, 2011)

FordGT90Concept said:


> ```
> 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:


```
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?


----------



## FordGT90Concept (Aug 24, 2011)

It might be the /B but could also be the tokens=*.  It works, that's all that matters.


----------



## NinjaNife (Aug 24, 2011)

FordGT90Concept said:


> 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


----------

