2

On my Android phone since years I use an app called 'Fastnote' for notetaking. The notes are automatically saved with a filename that corresponds to the first line of the file.

Such automatic saving is very convenient, but the result is that many of these filenames contain special characters such as " or \ (double quote or slash) which are valid in Android but not in Windows.

Every time I try to backup all my notes (about 1'800 files in 70 folders) onto my PC running Windows 10, those files won't be copied. I can create a zip file which I copy on my PC - so I have a 'backup'. But when I try to unzip this file on the PC, any file with an invalid character in the name won't be copied.

Is there a way to automatically strip all filenames from their invalid characters? This could happen either

  • already on the phone before copying

  • or during the copy operation via USB connection

  • or when unzipping in Windows

EDIT: I need to read the files on my PC, so it's not enough just to have a backup. I actually need to have a FULLY ACCESSIBLE backup on my PC. The only way to do this I see, is to convert the file names into something Windows can handle.

7
  • Do you still remember which Android version that was? I'm currently struggling with illegal characters in filenames, as well, but not on Windows but on Android itself: It seems that, at least in Android 12, characters that are illegal on Windows/NTFS are now also illegal on Android, whereas this was not the case previously.
    – balu
    Dec 11, 2021 at 23:51
  • @balu I last did an unzip in Android 9 and it substituted some illegal characters without any issue. I haven't gone beyond that version yet but might still do it this year.
    – 1NN
    Dec 12, 2021 at 18:46
  • @balu you can always use zip / unzip to validate your filenames in windows, then copy them back to your Android device. Backslash in filenames will create subdir in windows. See the comments to the answer below
    – 1NN
    Dec 12, 2021 at 18:57
  • "I last did an unzip in Android 9 and it substituted some illegal characters without any issue" -- Wait. Those "illegal" characters get replaced on your Android phone? How exactly did you do the unzipping? Maybe it's the app you used that did the replacing? The reason I'm asking is, on (my version of) Android 9 I can definitely use all file name characters that are illegal on NTFS / Windows without issue.
    – balu
    Dec 13, 2021 at 11:51
  • @balu I'm going on memory, might be wrong. I suggest you to ask a new question either here or on android stack exchange. I don't see sense in discussing this further through comments
    – 1NN
    Dec 13, 2021 at 12:45

1 Answer 1

3

The correct way to create a useful backup is just not to use the Android MTP interface for accessing those files.

Instead you should create a backup on-device via adb (requires to activate Development mode and Android Debug Bridge in device settings). Also on the PC side you have to install a minimal version of the Android SDK with ADB.

This has two advantages:

  1. All file-names are preserved - Windows does not have to handle them and therefore can't fail on it.
  2. Creating a backup on-device and later just downloading the combined archive is way more faster: the MTP protocol used by Windows Explorer is very slow, I would expect that the on-device backup creation is 10-20 times faster for such a high number of files.

The two step variant (create TAR archive on-device + download it)

Then create a backup archive on-device:

adb shell tar /sdcard/fastnode_backup.tar /sdcard/<path to fastnote files>

Afterwards you can download the created backup file from your device via

adb pull /sdcard/fastnode_backup.tar

One step variant (create TAR archive and stream it to PC)

Create backup on-device and transfer the created tar archive to the PC - this variant does not require any flash memory on-device):

adb exec-out 'cd /sdcard; tar -cf - <path to fastnote files in sdcard section>/' > fastnode_backup.tar

Or alternatively on devices running Android 8 and newer the fastnode_backup.tar should also appear in the Windows-Explorer view of your device. You can then download this backup file with all file-names preserved inside.

If you still need to access any of those files from within the archive use 7-Zip to extract the files, on your PC or elsewhere. 7-Zip has a built it detection and replacement for invalid file-name characters.

3
  • Thank you @Robert. That resolves part of my problem. However - and I guess I wasn't clear on that - I need to access the files on my PC, so I really need a way to convert the file names.
    – 1NN
    Apr 15, 2020 at 8:09
  • 1
    @1NN AFAIK 7-Zip can automatically replace illegal characters upon extraction from an archive. Hence try to open and extract the TAR archive with 7-Zip.
    – Robert
    Apr 15, 2020 at 8:15
  • Great! 7-zip Works as indicated! I'll mark your answer as correct, even if the true solution is in your comment. Thanks !
    – 1NN
    Apr 15, 2020 at 11:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .