<p>I quickly verified my system, here is what might help you to identfy:</p>

<pre><code>$ file wallet.dat 
wallet.dat: Berkeley DB (Btree, version 9, native byte-order)

$ file blocks/blk00233.dat 
blocks/blk00233.dat: data
</code></pre>

<p>and if you have a hexdump tool (this here should work on Unixoide type systems):</p>

<pre><code>$ hexdump -C wallet.dat | more
00000000  00 00 00 00 01 00 00 00  00 00 00 00 62 31 05 00  |............b1..|
... many, many zeros, and from time to time some numbers :-)
00001ff0  04 00 01 00 00 00 02 00  04 00 01 6d 61 69 6e 00  |...........main.|
</code></pre>

<p>whereas blooks are full of numbers...</p>

<pre><code>$ hexdump -C blk00233.dat | more
00000000  f9 be b4 d9 1f ad 06 00  02 00 00 00 f2 50 36 7e  |.............P6~|
00000010  af 4f e8 37 f7 2f 0f db  8b cf a1 3e 34 73 0d eb  |.O.7./.....&gt;4s..|
00000020  f9 ca 1d 05 00 00 00 00  00 00 00 00 76 89 01 91  |............v...|
00000030  46 d5 24 ed 48 bd ff ed  68 77 3e ca 28 0e b8 74  |F.$.H...hw&gt;.(..t|
00000040  30 73 cb aa 0e 32 d9 91  9f a9 ed 73 b1 d2 e5 54  |0s...2.....s...T|
00000050  87 bb 18 18 90 7d 19 02  fd c6 02 01 00 00 00 01  |.....}..........|
00000060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
</code></pre>

<p>as you don't want to do this for each and every file, you may want to tell your system what to do:</p>

<pre><code>for i in *.dat; do file $i; done
</code></pre>

CC BY-SA 3.0
2017-05-22T18:35:04.587Z
Wonderful that's exactly what I was looking for, thank you. Using `file` inside a for-loop I was able to find the Berkeley DB file.
William Robinson
CC BY-SA 3.0
2017-05-22T05:30:58.490Z
2017-05-22T05:30:58.490Z
pebwindkraft
<p>Here is another, perhaps quicker version:</p>

<pre><code>find /my/folder -exec file {} ";" | grep 'Berkeley'
</code></pre>

<p>This command will print the list of all files from <code>/my/folder</code>, which have the type of <code>Berkeley DB</code>. Above else, this is the type of the Bitcoin wallet files. </p>

CC BY-SA 3.0
2017-10-07T12:40:21.633Z
2017-10-07T14:08:20.943Z
2017-10-07T14:08:20.943Z
Datageek
<h3>Hello my friends!</h3>
<p>Here is my situation:</p>
<p>I accidentally deleted a partition on my HDD containing the only copy of my bitcoin wallet. Facepalm. After running data recovery tools, I've found and restored around 150 <code>.dat</code> files. Unfortunately, the recovery software assigns arbitrary names to these files, so I cannot identify which one is my BTC <code>wallet.dat</code>.</p>
<h3>My question :</h3>
<p>Is there a quick way or a utility that can confirm if a .dat file is a valid bitcoin wallet? I would like to run a script to iterate through each <code>.dat</code> and check it in order to find the bitcoin wallet among all the <code>.dat</code> files I recovered.</p>
<p>Worst comes to worst, I will just need to try to import each one, one-by-one ( (which sounds like an awful way to spend my afternoon tomorrow). I am still pretty new to BTC and unfamiliar with the set of tools it involves, so I am hoping there is a programatic way to do this :D</p>

<wallet><wallet.dat><wallet-recovery>
Identifying wallet file among soup of recovered .dat files
William Robinson
# Identifying wallet file among soup of recovered .dat files

(Asked by: username_0 on 2017-05-22)

### Hello my friends!

Here is my situation:

I accidentally deleted a partition on my HDD containing the only copy of my bitcoin wallet. Facepalm. After running data recovery tools, I've found and restored around 150 `.dat` files. Unfortunately, the recovery software assigns arbitrary names to these files, so I cannot identify which one is my BTC `wallet.dat`.

### My question :

Is there a quick way or a utility that can confirm if a .dat file is a valid bitcoin wallet? I would like to run a script to iterate through each `.dat` and check it in order to find the bitcoin wallet among all the `.dat` files I recovered.

Worst comes to worst, I will just need to try to import each one, one-by-one ( (which sounds like an awful way to spend my afternoon tomorrow). I am still pretty new to BTC and unfamiliar with the set of tools it involves, so I am hoping there is a programatic way to do this :D

**Tags:** wallet, wallet.dat, wallet-recovery


---

## 2 answers

### Answer by username_1 on 2017-05-22. Score: 1 | Accepted answer

I quickly verified my system, here is what might help you to identfy:

```
$ file wallet.dat 
wallet.dat: Berkeley DB (Btree, version 9, native byte-order)

$ file blocks/blk00233.dat 
blocks/blk00233.dat: data

```

and if you have a hexdump tool (this here should work on Unixoide type systems):

```
$ hexdump -C wallet.dat | more
00000000  00 00 00 00 01 00 00 00  00 00 00 00 62 31 05 00  |............b1..|
... many, many zeros, and from time to time some numbers :-)
00001ff0  04 00 01 00 00 00 02 00  04 00 01 6d 61 69 6e 00  |...........main.|

```

whereas blooks are full of numbers...

```
$ hexdump -C blk00233.dat | more
00000000  f9 be b4 d9 1f ad 06 00  02 00 00 00 f2 50 36 7e  |.............P6~|
00000010  af 4f e8 37 f7 2f 0f db  8b cf a1 3e 34 73 0d eb  |.O.7./.....>4s..|
00000020  f9 ca 1d 05 00 00 00 00  00 00 00 00 76 89 01 91  |............v...|
00000030  46 d5 24 ed 48 bd ff ed  68 77 3e ca 28 0e b8 74  |F.$.H...hw>.(..t|
00000040  30 73 cb aa 0e 32 d9 91  9f a9 ed 73 b1 d2 e5 54  |0s...2.....s...T|
00000050  87 bb 18 18 90 7d 19 02  fd c6 02 01 00 00 00 01  |.....}..........|
00000060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*

```

as you don't want to do this for each and every file, you may want to tell your system what to do:

```
for i in *.dat; do file $i; done

```

> **Comments:**
> **username_0**: Wonderful that's exactly what I was looking for, thank you. Using `file` inside a for-loop I was able to find the Berkeley DB file.  

---

### Answer by username_2 on 2017-10-07. Score: 0

Here is another, perhaps quicker version:

```
find /my/folder -exec file {} ";" | grep 'Berkeley'

```

This command will print the list of all files from `/my/folder`, which have the type of `Berkeley DB`. Above else, this is the type of the Bitcoin wallet files.


---

