# Getting CID of file by filename

**URL:** <https://discuss.ipfs.tech/t/getting-cid-of-file-by-filename/14257>\
**Category:** Help\
**Tags:** files\
**Created:** [May 18, 2022, 11:56am UTC](https://discuss.ipfs.tech/t/getting-cid-of-file-by-filename/14257 "2022-05-18T11:56:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sambhaji](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/sambhaji/32/6469_2.png) [@sambhaji](https://discuss.ipfs.tech/u/sambhaji)\
**Post date:** [May 18, 2022, 11:56am UTC](https://discuss.ipfs.tech/t/getting-cid-of-file-by-filename/14257/1 "2022-05-18T11:56:18Z")

</div>

I want to verify the file that I have is the same as that uploaded on ipfs. So I want to access the CID of a file if I have the file.

---

<div class="post-metadata">

**Author:** ![SionoiS](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/sionois/32/5103_2.png) [@SionoiS](https://discuss.ipfs.tech/u/SionoiS)\
**Post date:** [May 18, 2022, 12:17pm UTC](https://discuss.ipfs.tech/t/getting-cid-of-file-by-filename/14257/2 "2022-05-18T12:17:22Z")

</div>

> **[Command-line reference | IPFS Docs](https://docs.ipfs.io/reference/cli/#ipfs-add)**
>
> API documentation for the Go-IPFS command-line executable.

This command with `--only-hash` return the CID of the file then you can compare the 2.

Keep in mind that if the IPFS settings were different when the file was added the CID will be different.
