Save Snapchat files (Android) – Part 1

SnapchatIf you’re using Snapchat, chances are you want to save some of the pictures and/or videos you receive. Now you can.

I should start with a preface: You probably shouldn’t do this. Half the fun of Snapchat is knowing it’s a one-off, and there’s a sort of “honour among thieves” type of policy between users. That being said, I do like a challenge, even if a solution does make me look creepy.

What you’ll need

  1. I assume that if you’re reading this, you have Snapchat. If you don’t, you can grab it from one of the links on their website.
  2. An Android phone. So far, this solution only applies to Android. I’m currently playing around with a solution for Apple devices.
  3. A rooted phone. I probably haven’t thought hard enough about the problem, but from what I can tell, you need to have root access for this to work.
  4. The most useful tool of all – a Terminal Emulator. There are heaps of apps out there for changing permissions and fiddling with the filesystem, but nothing is better than the ol’ terminal.

The Script

Most of what does the work is inside this shell script:

When executed (before viewing anything), the script checks the two storage locations for Snapchat (images and video), loop through the list of files, and copies the data to a safe location (a place the app can’t touch). The unusual part of the script is the use of the cat command, which we need due to some filesystem limitations within Android. Also, keep in mind that the paths above are for my device (Samsung Galaxy SIII, running Jelly Bean 4.1). You may need to update them if the script is returning errors.

Setting up the script

If you are Unix-savvy, you probably already know how to do this. You can jump down to the “how-to” section below for some notes.

If you’re a little Unix-rusty, here’s what you need to do to get this script working.

  1. First, copy/paste the script above into a new text file. Save it as whatever you like and add the extension .sh. I called mine snapchat.sh.
  2. Transfer the script onto your phone using Android File Transfer (Mac) or just in Explorer (Windows). I usually just stick it in the sdcard’s “Downloads” folder. It actually doesn’t matter, as this location is temporary anyway.
  3. Open the Terminal Emulator. First switch to the root user by running the su command.

    Then, make the internal system writable by running:

    If this step isn’t working, you can try this app instead. It’s what I use, as it offers a one-click solution.

  4. Now that you’re root, we need to move the script to a place on the system to allow us to execute it without any permission errors. Thanks to an Android limitation, this will need to be done using cat. Note: Some people appeared to be having problems copying to /etc. I’m now using /data instead to avoid any difficulties. Everything except the path is the same.

    This outputs the contents of the script into a new copy located in /data. Feel free to change this location to basically anything on the phone’s internal storage.

  5. Remove the temporary copy of the script (not essential, just tidy):

  6. Once this is done, navigate to the folder you copied the script into (on the phone’s storage), and add execute permissions using chmod.

  7. All that’s left is a bit of cleanup:

    This will remount the internal storage as read-only (as it was before).

As far as set-up is concerned, that’s (thankfully) it!

How to

Now for the best part – saving files. You will need to use Terminal Emulator (or equivalent) to do this. Be aware that you need to use su, otherwise the script won’t find the files due to permission restrictions.

  1. “Snap received!”
  2. Open Snapchat and wait until your snaps are loaded. Do not open them. I can’t stress this enough. If you open them, the script will not find them.
  3. Jump to your Terminal Emulator and run:

    This will execute the script and tell you what it does (as it’s doing it).

  4. Once that’s complete (assuming no errors), you can view your snaps as normal. A copy should have been made in the location specified by the script (in my example, this is /storage/extSdCard/snapchat/)

And that’s all there is to it! Unfortunately, this process needs to be repeated every time new snaps come in. However, in part 2, we’ll be automating the whole process using Tasker, meaning that once you open the app, your files are saved. Very sneaky.

Update: Part 2 is now available!

Note: Feel free to add comments/suggestions or point out errors in the comments section below. I will be maintaining this post.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

 

31 thoughts on “Save Snapchat files (Android) – Part 1

  1. I seem to get the error “Bad mode” at step 4. I even used ES File explorer to move the .sh file into /etc/ but it then tells me “can’t execute: Permission denied”

    I am literally typing “chmod +x snapchat.sh” in step 4. Is that correct or is more information required?

    Any suggestions?
    (Samsung Galaxy S3, Android 4.1.2)

  2. @FloppleWopple Ah yes, my mistake. You just need to enable executable permissions. Some flavours of Unix allow the shorthand notation (+rwx).

    In this case you should be able to use the normal octal notation.

    >> chmod 755 snapchat.sh

    Also, there’s no need to prefix the command with “sh”, as the script becomes an app itself once it has permissions.

    This should let you execute the script. It’s been a while since I set this up on my machine, my memory gets a little rusty!

    • Hi Boom

      I’ve checked out your screenshot, and I think I’ve tracked down the error. It appears as though you set the permissions on the script, then copy it over to your phone storage. This creates a new set of permissions, so the chmod command needs to be run on the new copy of the file (not the original).

      This is my mistake (incorrect step order), so I’ve fixed up the blog post.

      Many many thanks!

  3. Hi im having troubles with following your instructions. im using a samsung galaxy s2 and ive saved my text file into the downloads area but im having trouble switching it to root user. please help

    • Hi Jeremiah

      If you’ve rooted the S2, you should be able to run the command “su” from a Terminal to get super user access.

      Which SuperUser app are you using? I use SuperSu (installs after rooting). Also, if you could provide a screenshot of your process that would help a bunch.

      Cheers
      Tim

  4. How much longer until part 2? Will the process done in Tasker be able to be done in AutomateIt?

    • Hi Ben. The next part will be quite soon. My setup uses Tasker and a plugin for it called SecureSettings. This combo allows me to trigger the script on the device as root whenever I launch SnapChat. I’ve not used AutomateIt, but if you’re able to execute scripts as root using this app, then it will 100% work.

  5. Currently having some problems at steps 3/4 setting up the script. I’m rooted on a Photon 4G and when I try to execute the command in step 4, it says that the system is read-only. I’m not sure why this is and would appreciate any help you might have.

    • Hi John. It sounds like the remount command isn’t working from the terminal. You can try give this app a go. It’s the one I use and I’ve never had a problem with it.

    • Hi joey. You need to chmod the script to 755 *after* you move it to /etc/. Otherwise, the permissions won’t be correct.

  6. Awesome guide! Problem being is that I can’t seem to get it to work….
    http://imgur.com/f0pHwA0

    I read your other comments about changing permissions after moving it to /data/, and I followed your instructions, but I still can’t seem to get the emulator to recognize the .sh file.

    What am I doing wrong?

    • Hi Damian

      It appears as though the cat command isn’t transferring the script. Without having the actual device, it’s hard to know exactly why. Can you see the script when you go to /data and run ls? Also, try setting the script to 777 (all permissions).

    • Same problem. I cannot see the script in explorer when I go to /data

    • Never mind I enabled root explorer in ES File explorer and now I have permissions to read/write and see files in there :)

    • Meh still getting the same error in terminal after all that…

    • Ok. Was typing “cat snapchat.sh > /data/snapchat.sh” instead of “cat /data/snapchat.sh”

  7. I had some troubles that looked a lot like what other people had run into, but just altering the permissions wasn’t fixing it for me; thought I’d share what I figured out and a few tips for other newbies such as myself.

    1) If you copy/paste this script into a text editor on Windows, make sure to save it with Unix style line endings. This held me up for a long time (hint: Notepad++).
    2) If typing a lot of console commands on that little keyboard isn’t your thing, you can copy the script to /data/ (or anywhere else) using something like Root Explorer. You can also set the permissions in root explorer (755 = Read:All, Write:Owner only, Execute:All).
    3) You can use Script Manager (https://play.google.com/store/apps/details?id=os.tools.scriptmanager) to execute the script instead of the terminal (be sure to check the su option) and you can add a home screen shortcut to execute it as well.

    Great tutorial; thanks for figuring this stuff out.

    • Cheers for the extra tips. There are so many ways to do things in Android that there will inevitably be a few problems.

  8. I am new to android. I just got the S4, I am just wondering how do I root my phone using a Mac? Thank you.

  9. Hi,

    I think I might be doing something wrong here. I tried running the script but got the following error back:

    “/data/snapchat.sh: 8: Syntax error: Bad substitution”

    I changed the code to direct the files to my sdcard as it appears on my phone (Acer Liquid MT running 2.3.6) but other than that the code remains unchanged. Any ideas?

    • Hi Eanna. It seems like the internal sh app doesn’t like the syntax of the renaming commands in version 2.3 of Android. I’ll have to look into a solution, but it seems like this is a dealbreaker for the moment.

  10. I just have a question pertaining to your code. I rooted my phone but the ” received_image_snaps” folder is in a different location. Would i have to change that and the video one to their respective locations for this to work?

    Many thanks in advance.

    • Hi Bob. Yep, you can change the path to whatever it happens to be. That’s why I’ve decided to share the script instead of releasing an app. You just never know with Android :)

  11. I have gotten everything to work in part 1 and 2 but the script must be faulty for my phone HTC Amaze 4g with SpeedRom 8.0. I have a couple ways of accessing the sdcards from ES File Explorer. “/mnt/sdcard” “/sdcard/” /mnt/sdcard2/” “/sdcard2/” “/sdcard/ext_sd/” etc… these are not the same as your galaxy s3 and im not sure which to choose but its not saving anything into the target path after running the script.

    • Hi RC. I’m not sure what restrictions are on your phone. You can try to set the destination path to somewhere on the same card as the source files. Without a screenshot or some more info, I can’t test out solutions on my own device. Cheers

    • I have changed the save target path from your script. (Don’t worry about the video files I don’t know where they are saved at yet.) So far I’ve done everything else as to your instructions.

      #!/system/bin/sh
      set -x verbose

      cd /data/data/com.snapchat.android/cache/received_image_snaps/
      if ls *.nomedia &> /dev/null; then
      for file in *.nomedia
      do
      cat “$file” > “/mnt/sdcard/s/${file/.nomedia}”
      done
      fi

      cd /data/data/com.snapchat.android/cache/received_video_snaps/
      if ls *.nomedia &> /dev/null; then
      for file in *.nomedia
      do
      cat “$file” > “/mnt/sdcard/s/${file/.nomedia}”
      done
      fi
      exit

  12. I get the “not found” errors no matter what I do. The script is there in /data. I am root. I can do nano sc.sh and see the contents of the file.

    But when I run it just as sc.sh I get “not found”. It’s chmod’d to 777. Any ideas?

  13. I’ve tried it with permissions set to both 755 and 777 in both the data and etc folder but I keep getting this error

    exec /system/bin/sh ‘/etc/snapchat.sh’
    /bin/sh ‘/etc/snapchat.sh’ <
    +
    : not foundat.sh[3]:
    + cd /data/data/com.snapchat.android/cache/received_image_snaps/
    /etc/snapchat.sh[4]: cd: /data/data/com.snapch: Permission deniedceived_image_snaps/
    ' unexpectedt.sh[7]: syntax error: 'do