Refresh Android mediastore using adb

前端 未结 5 947
鱼传尺愫
鱼传尺愫 2020-12-04 08:42

I\'m using adb to sync music on an android phone. Essentially, I rm the existing music directory and push replacement music files.

I\'d like to be able to use adb to

5条回答
  •  温柔的废话
    2020-12-04 09:26

    If you have rooted your phone, you can use this script I’ve written, which has the advantage of keeping track of which files have already been updated:

    #!/system/bin/env busybox ash
    
    MUSIC_LIBRARY=/sdcard/MusicLibrary
    
    LAST_UPDATE="$(stat -c %Y "$MUSIC_LIBRARY/.last-update")"
    
    find "$MUSIC_LIBRARY" -type f ! -iname ".last-update" | (
      while read f; do
        if ! test "$LAST_UPDATE" -ge "$(stat -c %Y "$f")"; then
          am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d "file://$f"
          touch "$f"
        else
          echo "Not updated: \`$f'"
        fi
      done
    )
    
    touch "$MUSIC_LIBRARY/.last-update"
    

提交回复
热议问题