# Get all uploaded files in Roam Research to Obsidian

**URL:** <https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573>\
**Category:** Help\
**Created:** [February 24, 2021, 11:03am UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573 "2021-02-24T11:03:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikeriss](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/m/b5ac83/32.png) [@mikeriss](https://forum.obsidian.md/u/mikeriss)\
**Post date:** [February 24, 2021, 11:03am UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/1 "2021-02-24T11:03:39Z")

</div>

Hallo, I just moved from Roam Research to Obsidian. I was able to convert the daily notes date formats and the date references using a python script from youtube.

Now I would like to download all the uploaded files (Roam Research uses firebase storage) to obsidian before I cancel my rs subcription.  
I couldn’t find any script so far. Has anyone done this already?

---

<div class="post-metadata">

**Author:** ![pmbauer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pmbauer/32/10201_2.png) [@pmbauer](https://forum.obsidian.md/u/pmbauer)\
**Post date:** [February 25, 2021, 1:32am UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/2 "2021-02-25T01:32:44Z")

</div>

You can try these two commands or modify them to your use (run from your vault root).

**_I recommend making a backup first or managing the vault with git._**

First, download a markdown export of all your notes and extract the zip file. The commands below can be run in that extracted folder.

## Download all images off firebase and store them in `_attachment/img`.

```bash
mkdir -p _attachment/img && \
  sed -n 's/.*\[](\(https:\/\/firebasestorage.*\)).*/\1/gp' *.md */*.md \
    | sort | uniq \
    | sed 's/.*%2F\(.*\)?alt.*/\1\t\0/' \
    | awk '{system("wget -O _attachment/img/" $1 " " $2) }'

```

## Then update all the links.

```bash
sed -i 's/!\[](https:\/\/firebasestorage.*%2F\(.*\)?alt.*)/![[_attachment\/img\/\1]]/g' *.md */*.md

```

### Note for Mac Users

If you are trying this on a Mac, you will need to install and use gsed/gawk, a GNU userland, and a non-ancient version of bash.

```auto
brew install gnu-sed gawk gnutls bash # install gnu userland and non-ancient bash
/usr/local/bin/bash # run modern bash
export PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH
export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:$PATH

# now you should be able to run the scripts above

```

---

<div class="post-metadata">

**Author:** ![pmbauer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pmbauer/32/10201_2.png) [@pmbauer](https://forum.obsidian.md/u/pmbauer)\
**Post date:** [February 27, 2021, 6:22pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/3 "2021-02-27T18:22:51Z")

</div>

**UPDATE: 2021-08-05**  
These instructions to batch-delete uploaded firebase attachments no longer works. Also,  
the roam forum was decommissioned.

~~After downloading all my uploads and converting them to local assets, I wasn’t comfortable leaving all of them in firebase. Roam has no provision for upload management, but if you can use Chrome/Firefox dev tools, this may work for you~~

~~[https://forum.roamresearch.com/t/delete-files-uploaded-to-firebase/3811](https://forum.roamresearch.com/t/delete-files-uploaded-to-firebase/3811)~~

---

<div class="post-metadata">

**Author:** ![argentum](https://forum.obsidian.md/user_avatar/forum.obsidian.md/argentum/32/7733_2.png) [@argentum](https://forum.obsidian.md/u/argentum)\
**Post date:** [March 12, 2021, 6:15pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/4 "2021-03-12T18:15:49Z")

</div>

@mikeriss in case any of the answers above solves your question, could you mark it as solved? Thanks!

---

<div class="post-metadata">

**Author:** ![jimw](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jimw](https://forum.obsidian.md/u/jimw)\
**Post date:** [April 18, 2021, 9:32am UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/5 "2021-04-18T09:32:25Z")

</div>

OK, I’ve done the date changes now I’m, onto this one!!

How do I actually do this?

1. I presume I navigate to the root of the vault?
2. Do I then run each line as a command or as a .sh file?

Really sorry to keep hassling, but I’m not sure how to get started with this…

Thanks again!

Jim

---

<div class="post-metadata">

**Author:** ![blippybloopy](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/b/7993a0/32.png) [@blippybloopy](https://forum.obsidian.md/u/blippybloopy)\
**Post date:** [April 18, 2021, 1:33pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/6 "2021-04-18T13:33:25Z")

</div>

They actually only gave you two commands. The first one is very long, so they split it up over multiple lines using backslashes, which tells the shell “don’t run it yet when I press Enter, I’m going to continue typing the command on the next line.” It would work as a script, or as a multiple-line command, or you could run it as a single-line command if you prefer by removing the trailing backslashes (but keep the vertical pipe characters, they’re important).

---

<div class="post-metadata">

**Author:** ![pmbauer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pmbauer/32/10201_2.png) [@pmbauer](https://forum.obsidian.md/u/pmbauer)\
**Post date:** [April 18, 2021, 7:57pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/7 "2021-04-18T19:57:14Z")

</div>

no worries at all, exactly what @blippybloopy said. these are just two commands. you can select the entire command, copy and paste them into your terminal. remember to back everything up first.

---

<div class="post-metadata">

**Author:** ![stelli](https://forum.obsidian.md/user_avatar/forum.obsidian.md/stelli/32/14165_2.png) [@stelli](https://forum.obsidian.md/u/stelli)\
**Post date:** [May 3, 2021, 4:38am UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/8 "2021-05-03T04:38:42Z")

</div>

@pmbauer thanks for your work on this! Which shell did you write that block (your download ‘script’) in/for? Blindly pasted into zsh (the macOS default shell), it doesn’t parse correctly. It also doesn’t seem to work in bash, sh, or tcsh? (That’s after installing gsed from MacPorts and using it instead of BSD sed).

Edit: I ended up using:

```bash
mkdir -p _attachment/img

gsed -n 's/.*\[](\(https:\/\/firebasestorage.*\)).*/\1/gp' *.md */*.md | sort | uniq | gsed 's/.*%2F\(.*\)?alt.*/\1\t\0/' | awk '{system("wget -O _attachment/img/" $1 " " $2) }'

```

Where `gsed` is GNU Sed, installed from [MacPorts](https://ports.macports.org/port/gsed/summary). I think there’s at least one spare `|` in the original script causing it to fail at the start but it took some playing with it and compressing to one line before zsh was happy.

Edit 2: May also want to do this for Roam PDF embeds.

```bash
gsed -n 's/.*pdf.*\(https:\/\/firebasestorage.*\).*/\1/gp' *.md */*.md | sort | uniq | gsed 's/.*%2F\(.*\)?alt.*/\1\t\0/' | awk '{system("wget -O _attachment/img/" $1 " " $2) }'

gsed -i 's/{{pdf:.*https:\/\/firebasestorage.*%2F\(.*\)?alt.*/![[_attachment\/img\/\1]]/g' *.md */*.md

```

I definitely suggest using something like a find all in a text editor you’re familiar with, particularly if you’re going to be deleting the files from firebase after (you don’t want to leave anything behind). Just search for `firebasestorage`

---

<div class="post-metadata">

**Author:** ![pmbauer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pmbauer/32/10201_2.png) [@pmbauer](https://forum.obsidian.md/u/pmbauer)\
**Post date:** [May 3, 2021, 2:03pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/9 "2021-05-03T14:03:18Z")

</div>

it’s bash; as noted in the instructions, you’ll need a gnu userland

Mac’s default version of bash is pretty ancient. If you can get it to work on bash 3.2.57 (mac’s default) great. I’ve never tried.

---

<div class="post-metadata">

**Author:** ![pmbauer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pmbauer/32/10201_2.png) [@pmbauer](https://forum.obsidian.md/u/pmbauer)\
**Post date:** [May 3, 2021, 2:13pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/10 "2021-05-03T14:13:54Z")

</div>

I added an extra section for mac users. The script doesn’t have an extra | and should just work on linux. You will likely need to tweak some things for your mac

---

<div class="post-metadata">

**Author:** ![stelli](https://forum.obsidian.md/user_avatar/forum.obsidian.md/stelli/32/14165_2.png) [@stelli](https://forum.obsidian.md/u/stelli)\
**Post date:** [May 3, 2021, 4:14pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/11 "2021-05-03T16:14:07Z")

</div>

> [@pmbauer](#):
>
> Mac’s default version of bash is pretty ancient.

Oh, that figures. I didn’t realize that was also horribly out of date. Cheers!

---

<div class="post-metadata">

**Author:** ![syncretizm](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@syncretizm](https://forum.obsidian.md/u/syncretizm)\
**Post date:** [July 24, 2021, 3:05pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/12 "2021-07-24T15:05:34Z")

</div>

This looks like greek to me… Anyone can share how to do this in Windows?

---

<div class="post-metadata">

**Author:** ![astrophoenix](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@astrophoenix](https://forum.obsidian.md/u/astrophoenix)\
**Post date:** [August 27, 2021, 9:52pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/13 "2021-08-27T21:52:53Z")

</div>

you have an extra pipe in there! you can’t pipe mkdir to sed, you already had the `&&` to connect them.

---

<div class="post-metadata">

**Author:** ![astrophoenix](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@astrophoenix](https://forum.obsidian.md/u/astrophoenix)\
**Post date:** [August 27, 2021, 9:59pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/14 "2021-08-27T21:59:07Z")

</div>

it also didn’t let me run that pipeline (on linux) until I stripped the comments out (and the extra whitespace after the backslash).

```auto
mkdir -p _attachment/img && \
  sed -n 's/.*\[](\(https:\/\/firebasestorage.*\)).*/\1/gp' *.md */*.md \
  | sort | uniq \
  | sed 's/.*%2F\(.*\)?alt.*/\1\t\0/' \
  | awk '{system("wget -O _attachment/img/" $1 " " $2) }'

```

---

<div class="post-metadata">

**Author:** ![pmbauer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pmbauer/32/10201_2.png) [@pmbauer](https://forum.obsidian.md/u/pmbauer)\
**Post date:** [August 27, 2021, 10:17pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/15 "2021-08-27T22:17:57Z")

</div>

congrats, you found a typo, here’s a star ⭐

---

<div class="post-metadata">

**Author:** ![astrophoenix](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@astrophoenix](https://forum.obsidian.md/u/astrophoenix)\
**Post date:** [August 28, 2021, 3:05am UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/16 "2021-08-28T03:05:28Z")

</div>

thanks!

---

<div class="post-metadata">

**Author:** ![astrophoenix](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/a/e8c25b/32.png) [@astrophoenix](https://forum.obsidian.md/u/astrophoenix)\
**Post date:** [August 31, 2021, 1:49am UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/17 "2021-08-31T01:49:31Z")

</div>

for some reason, I had a bunch of image files stored without a filename extension. this confused obsidian on my mac, and it didn’t end up syncing those files up. so of course I wrote some scripts to rename them all, to add the extension, and update references to them. after that, they synced.

remember to back up first (or use git)

first, I needed a list of them all (start this in the vault folder) … I looked at the files first to make sure they’re all .png or .jpg files in reality.

```auto
cd _attachment/img
ls |grep -v '\.' | xargs file --extension grep -Ev 'png|jpeg'

```

if that gives any output, you have some additional filetypes I didn’t, and you’ll have to adjust the perl script accordingly.

next I saved the list of filenames:

```auto
ls |grep -v '\.' > /tmp/list.txt
cd ../..

```

then I wrote a perl script to rename the file (using `git mv ...` because I have the vault tracked in git; if you don’t, take `git` out of the command in the script)

here’s how to run the script from the top folder of the vault (I called it ext.pl)

```auto
ext.pl < /tmp/list.txt

```

it took 3 minutes to run on my m1 mac, because I have over 7,000 files, and for every every one of the attachments without an extension, it checks every single file in the vault.

here’s the text of the perl script:

```perl
#!/usr/bin/perl -w

# takes an image file with no extension, runs it through file, then assumes it will be jpeg or png, updates all references
my $path = './_attachment/img/';
while ( $line = <> )
{
    chomp $line;
    my $fn = $line;
    chomp $fn;
    my $file = `file --extension $path$fn`;
    chomp $file;
    print "$file\n";
    $file =~ m/$fn: (png|jpeg)/;
    my $ext = $1;

    my $cmd = "find . -name \\*.md -print0 | xargs -0 perl -p -i -e \"s/$fn/$fn.$ext/g\"";
    print $cmd, "\n";
    system($cmd) == 0 or die "$?";
    my $mv = "git mv \"$path$fn\" \"$path$fn.$ext\"";
    print $mv, "\n";
    system($mv) == 0 or die "$?";
}

```

---

<div class="post-metadata">

**Author:** ![marouk\_d](https://forum.obsidian.md/user_avatar/forum.obsidian.md/marouk_d/32/22248_2.png) [@marouk\_d](https://forum.obsidian.md/u/marouk_d)\
**Post date:** [November 18, 2021, 10:08pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/19 "2021-11-18T22:08:17Z")

</div>

I had an issue with the bash script but it was related to my page names in roam (I think I had colons or quotes which caused the regexp to fail). Anyway I should be able to get this to work, thanks!

---

<div class="post-metadata">

**Author:** ![justinj01](https://forum.obsidian.md/user_avatar/forum.obsidian.md/justinj01/32/23022_2.png) [@justinj01](https://forum.obsidian.md/u/justinj01)\
**Post date:** [December 11, 2021, 2:44pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/20 "2021-12-11T14:44:54Z")

</div>

Does anyone know if Roam has changed the way things work here? With this script, I’m seeing:

```auto
Resolving 0 (0)... 0.0.0.0
Connecting to 0 (0)|0.0.0.0|:80... failed: Connection refused.

```

And this makes sense, I think because the my firebase links are landing on a page with this:

```auto
{
  "error": {
    "code": 400,
    "message": "Invalid HTTP method/URL pair."
  }
}

```

I thought maybe they made it so you needed to be logged into Roam before the links would work, but not so much. Anyone know what’s going on here? I’d love to get moved over to Obsidian completely.

---

<div class="post-metadata">

**Author:** ![pmbauer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pmbauer/32/10201_2.png) [@pmbauer](https://forum.obsidian.md/u/pmbauer)\
**Post date:** [December 11, 2021, 7:08pm UTC](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/21 "2021-12-11T19:08:10Z")

</div>

Very possibly. I haven’t run this script in nearly a year and all my previous content on there is purged.

[Next page](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573.md?page=2)
