Jump to content

Find the "Space Consumers" on Android Phone, access Storage (internal and SD card)


rudi
 Share

Recommended Posts

Hello,

 

I found a couple of threads asking quite similar questions, but without finding a "straight" solution to Access the internal phone storage as well as the plugged in SD-Card.

 

While the SD Card is quite an easy Job (shutdown phone, remove SD, plug into some Card Reader, Access it using a drive letter), the internal storage isn't accessible this way.

 

Of course I *CAN* Access all the (regular visible) Content, when connected to a Windows box.

 

But this way I cannot estimate, where all the space was eaten up. So I'd like to know, how to address the "root" Folder of the internal storage of my Android Phone to get it's subfolders and files. Going through the whole Folder tree recursively isn't my Problem, it's just howto address the very first Folder and then to read all files (with sizes) and names of the subfolders.

 

 

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

  • 4 weeks later...

Hello again,

searching for an approach for PowerShell, with the help of "Get-PnpDevice" at least I could retrieve some additional Information for a Samsung Android phone (A SD Card is inserted)

So how to use These IDs to Access the internal storage? Any suggestions appreciated 😃

 

PS C:\temp> Get-PnpDevice | ? {$_.friendlyname -like "*android*"} | fl


Caption                     : SAMSUNG_Android
Description                 : ADB-Gerät
InstallDate                 :
Name                        : SAMSUNG_Android
Status                      : OK
Availability                :
ConfigManagerErrorCode      : CM_PROB_NONE
ConfigManagerUserConfig     : False
CreationClassName           : Win32_PnPEntity
DeviceID                    : USB\VID_04E8&PID_6860&MI_03\7&21AD9740&0&0003
ErrorCleared                :
ErrorDescription            :
LastErrorCode               :
PNPDeviceID                 : USB\VID_04E8&PID_6860&MI_03\7&21AD9740&0&0003
PowerManagementCapabilities :
PowerManagementSupported    :
StatusInfo                  :
SystemCreationClassName     : Win32_ComputerSystem
SystemName                  : WX-0111
ClassGuid                   : {88bae032-5a81-49f0-bc3d-a4ff138216d6}
CompatibleID                : {USB\Class_ff&SubClass_42&Prot_01, USB\Class_ff&SubClass_42, USB\Class_ff}
HardwareID                  : {USB\VID_04E8&PID_6860&REV_0400&MI_03, USB\VID_04E8&PID_6860&MI_03}
Manufacturer                : WinUsb-Gerät
PNPClass                    : USBDevice
Present                     : True
Service                     : WINUSB
PSComputerName              :
Class                       : USBDevice
FriendlyName                : SAMSUNG_Android
InstanceId                  : USB\VID_04E8&PID_6860&MI_03\7&21AD9740&0&0003
Problem                     : CM_PROB_NONE
ProblemDescription          :

 

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Hello,

searching the web I came across this PowerShell Script:

Crawl_Android.ps1 dropped with comments here: https://gist.github.com/cveld/8fa339306f8504095815#file-crawl_android-ps1

 

That's Pretty close to what I'm Looking for, the ouput of this script should be suitable to catch the "space eating items" on Android internal storage.

 

# http://blogs.technet.com/b/heyscriptingguy/archive/2013/04/26/use-powershell-to-work-with-windows-explorer.aspx
$o = New-Object -com Shell.Application
$folder = $o.NameSpace(0x11)

# https://msdn.microsoft.com/en-us/library/windows/desktop/bb774096(v=vs.85).aspx
# ShellSpecialFolderConstants.ssfDRIVES == 0x11

$items = $folder.Items()
for ($i= 0; $i -lt $items.Count; $i++) {
    write-output ([string]$i + ": " + $items.Item($i).Name)
}
$choice = Read-Host "Make your choice"

$android = $items.Item([int]$choice)
$root = $android.GetFolder()

# FolderItem versus FolderItems

$maxdepth = Read-Host "Max depth"

Function Write-Items($item, $depth, $maxdepth) {
    if ($depth -ge $maxdepth) {
        return;
    }
    $indent = ""
    for ($i = 0; $i -lt $depth; $i++) {
        $indent += "   ";
    }
    #write-output ($indent + "Name: " + $item.name)
    if ($item.Title) {
        $hash = @{
            Name = $item.Title
            Size = $null #$item.ParentFolder.GetDetailsOf($item, 2)
            Modified = $null #$item.ParentFolder.GetDetailsOf($item, 3)
            Parent = $item.ParentFolder.Title
            Level = $depth
        }
        $Object = New-Object PSObject -Property $hash            
        write-output $object
    } else {
        $hash = @{
            Name = $item.Name
            Size = $item.Parent.GetDetailsOf($item, 2)
            Modified = $item.Parent.GetDetailsOf($item, 3)
            Parent = $item.Parent.Title
            Level = $depth
        }
        $Object = New-Object PSObject -Property $hash            
        Write-Output $object
    }
    if ($item.Count -gt 0) {
        # $item is a folder with its own items
        for ($i = 0; $i -lt $item.Count) {
            $item2 = $item.item($i)
            Write-Items $item2 $depth+1 $maxdepth
        }

    }
    else { 
        if ($item.Items) {
            $items = $item.Items()
            if ($items.Count -gt 0) {
                foreach ($i in $items) {
                    if ($i.IsFolder) {
                        $folder = $i.GetFolder()
                        Write-Items $folder ($depth+1) $maxdepth
                    }
                    else {                    
                        Write-Items $i ($depth+1) $maxdepth
                    }
                }
            }
        }
        else {
            # .Count == 0 and no Items present
            # we don't need to do anything further here
        }
    }
}

Write-Items $root 0 $maxdepth | Out-GridView

 

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

To start you up :

Local $oShellApplication = ObjCreate("Shell.Application")
Local $oShellFolder = $oShellApplication.NameSpace(0x11)
Local $oShellFolderItems = $oShellFolder.Items()
For $oFolder in $oShellFolderItems
  ; ConsoleWrite ($oFolder.name & @CRLF)
  If $oFolder.name = "Moto G Play" Then ExitLoop
Next
Local $oRoot = $oFolder.GetFolder
Local $oRootItems = $oRoot.Items()
For $oSource in $oRootItems
  ; ConsoleWrite ($oSource.name & @CRLF)
  If $oSource.name = "Stockage interne partagé" Then ExitLoop
Next
$oRoot = $oSource.GetFolder
$oRootItems = $oRoot.Items()
For $oSource in $oRootItems
  ConsoleWrite ($oSource.name & "/" & $oSource.IsFolder & @CRLF)
Next

That accesses internal data. 

Link to comment
Share on other sites

Hello @Nine

thanks for your Reply. I think I've seen your example when searching for this Task before, but cannot find it again?

I think I'm Pretty close now:

; *** Start added by AutoIt3Wrapper ***
#include <GUIConstantsEx.au3>
; *** End added by AutoIt3Wrapper ***
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <debug.au3>


Local $oShellApplication = ObjCreate("Shell.Application")
Local $oShellFolder = $oShellApplication.NameSpace(0x11)
Local $oShellFolderItems = $oShellFolder.Items()

Dim $aFolders[$oShellFolderItems.count() + 1][3] = [[$oShellFolderItems.count()]]


$Pointer = 1
For $oFolder In $oShellFolderItems
    $aFolders[$Pointer][1] = $oFolder.name
    $aFolders[$Pointer][2] = $oFolder
    $Pointer += 1
Next


$Ctrl_H = 25
$Gap = 5

$Gui_W = 500
$Gui_H = $aFolders[0][0] * ($Ctrl_H + $Gap) + $Gap * 5
$MyGui = GUICreate("Select your Phone", $Gui_W, $Gui_H)

$aFolders[1][0] = GUICtrlCreateButton($aFolders[1][1], $Gap, $Gap, $Gui_W - 2 * $Gap, $Ctrl_H)
Opt("Guicoordmode", 2)
For $i = 2 To $aFolders[0][0]
    $aFolders[$i][0] = GUICtrlCreateButton($aFolders[$i][1], -1, $Gap)
Next
Opt("Guicoordmode", 1)

GUISetState()

While 1
    $Msg = GUIGetMsg()
    If $Msg = $GUI_EVENT_CLOSE Then ExitLoop
    For $i = 1 To $aFolders[0][0]
        If $Msg = $aFolders[$i][0] Then
            $oFolder=$aFolders[$i][2] ; this is the choosen entry for the phone
            GUIDelete($MyGui)
            MsgBox(0, "Your choice", $aFolders[$i][1])
            ExitLoop 2
        EndIf
    Next
WEnd

Local $oRoot = $oFolder.GetFolder
Local $oRootItems = $oRoot.Items()

Dim $aRootDirs[$oRootItems.count()+1][3]=[[$oRootItems.count()]]


$Pointer=1
For $oSource In $oRootItems
        $aRootDirs[$Pointer][1] = $oSource.name
    $aRootDirs[$Pointer][2] = $oSource
    $Pointer += 1
Next





$Gui_H = $aRootDirs[0][0] * ($Ctrl_H + $Gap) + $Gap * 5
$Gui_W = 250
$MyGui = GUICreate("Select internal storage", $Gui_W, $Gui_H)

$aRootDirs[1][0] = GUICtrlCreateButton($aRootDirs[1][1], $Gap, $Gap, $Gui_W - 2 * $Gap, $Ctrl_H)
Opt("Guicoordmode", 2)

For $i = 2 To $aRootDirs[0][0]
    $aRootDirs[$i][0] = GUICtrlCreateButton($aRootDirs[$i][1], -1, $Gap)
Next
GUISetState()

While 1
    $Msg = GUIGetMsg()
    If $Msg = $GUI_EVENT_CLOSE Then ExitLoop
    For $i = 1 To $aRootDirs[0][0]
        If $Msg = $aRootDirs[$i][0] Then
            $oSource=$aRootDirs[$i][2] ; this is the choosen entry for the phone
            GUIDelete($MyGui)
            MsgBox(0, "Your choice", $aRootDirs[$i][1])
            ExitLoop 2
        EndIf
    Next
WEnd


$oRoot = $oSource.GetFolder
$oRootItems = $oRoot.Items()
For $oSource In $oRootItems
    ConsoleWrite($oSource.name & "/" & $oSource.IsFolder & @CRLF)
Next

 

the Output is this:

>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\temp\AndroidCrawler-Autoit.au3
+>14:46:34 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\temp\AndroidCrawler-Autoit.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
Samsung/True
Android/True
Music/True
Podcasts/True
Ringtones/True
Alarms/True
Notifications/True
Pictures/True
Movies/True
Download/True
DCIM/True
Playlists/True
anvSyncDroid/True
WhatsApp/True
domobile/True
brouter/True
Locus/True
DIGITUS Plug&View/True
wsandroid/True
cc.dict.dictcc/True
ShareMemo/True
secured_com.samsung.smartviewad/True
360/True
data/True
MJXRCFPV_P/True
MJXRCFPV_V/True
mycallbox/True
Documents/True
LazyList/True
com.facebook.orca/True
+>14:46:47 AutoIt3.exe ended.rc:0
+>14:46:47 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 14.32

So I see all the Folders, could you give me a hint howto investigate all the "childs" of These Folder (later on file) objects?

Especially the size is what I'm Looking for.

And sorry for the UPPER-lower typos, that's autocorrect and it would be too much work to backrev all These wrong "UPPERCASES"...

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Final step now is just to catch the *SIZE* of the files, howto?

 

$NextSize = $oSource.size for File-Objects" obviously is not the correct Approach 😒 for getting file sizes of files stored in the phone. For files on local disks this is returning the appropriate size in Bytes...

And another Thing is that it seems, that for the Phone the SD-Card cannot be accessed this way? (no child objects found at all vor "Card")

recursing is working fine now:

 

; *** Start added by AutoIt3Wrapper ***
#include <GUIConstantsEx.au3>
; *** End added by AutoIt3Wrapper ***
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <debug.au3>


Local $oShellApplication = ObjCreate("Shell.Application")
Local $oShellFolder = $oShellApplication.NameSpace(0x11)
Local $oShellFolderItems = $oShellFolder.Items()

Dim $aFolders[$oShellFolderItems.count() + 1][3] = [[$oShellFolderItems.count()]]


$Pointer = 1
For $oFolder In $oShellFolderItems
    $aFolders[$Pointer][1] = $oFolder.name
    $aFolders[$Pointer][2] = $oFolder
    $Pointer += 1
Next


$Ctrl_H = 25
$Gap = 5

$Gui_W = 500
$Gui_H = $aFolders[0][0] * ($Ctrl_H + $Gap) + $Gap * 5
$MyGui = GUICreate("Select your Phone", $Gui_W, $Gui_H)

$aFolders[1][0] = GUICtrlCreateButton($aFolders[1][1], $Gap, $Gap, $Gui_W - 2 * $Gap, $Ctrl_H)
Opt("Guicoordmode", 2)
For $i = 2 To $aFolders[0][0]
    $aFolders[$i][0] = GUICtrlCreateButton($aFolders[$i][1], -1, $Gap)
Next
Opt("Guicoordmode", 1)

GUISetState()

$pre="//"

While 1
    $Msg = GUIGetMsg()
    If $Msg = $GUI_EVENT_CLOSE Then ExitLoop
    For $i = 1 To $aFolders[0][0]
        If $Msg = $aFolders[$i][0] Then
            $oFolder = $aFolders[$i][2] ; this is the choosen entry for the phone
            GUIDelete($MyGui)
            MsgBox(0, "Your choice", $aFolders[$i][1])
            $pre &= $aFolders[$i][1] & "/"
            ExitLoop 2
        EndIf
    Next
WEnd

Local $oRoot = $oFolder.GetFolder
Local $oRootItems = $oRoot.Items()

Dim $aRootDirs[$oRootItems.count() + 1][3] = [[$oRootItems.count()]]


$Pointer = 1
For $oSource In $oRootItems
    $aRootDirs[$Pointer][1] = $oSource.name
    $aRootDirs[$Pointer][2] = $oSource
    $Pointer += 1
Next





$Gui_H = $aRootDirs[0][0] * ($Ctrl_H + $Gap) + $Gap * 5
$Gui_W = 250
$MyGui = GUICreate("Select internal storage", $Gui_W, $Gui_H)

$aRootDirs[1][0] = GUICtrlCreateButton($aRootDirs[1][1], $Gap, $Gap, $Gui_W - 2 * $Gap, $Ctrl_H)
Opt("Guicoordmode", 2)

For $i = 2 To $aRootDirs[0][0]
    $aRootDirs[$i][0] = GUICtrlCreateButton($aRootDirs[$i][1], -1, $Gap)
Next
GUISetState()

While 1
    $Msg = GUIGetMsg()
    If $Msg = $GUI_EVENT_CLOSE Then ExitLoop
    For $i = 1 To $aRootDirs[0][0]
        If $Msg = $aRootDirs[$i][0] Then
            $oSource = $aRootDirs[$i][2] ; this is the choosen entry for the phone
            GUIDelete($MyGui)
            MsgBox(0, "Your choice", $aRootDirs[$i][1])
            $pre &= $aRootDirs[$i][1] & "/"
            ExitLoop 2
        EndIf
    Next
WEnd


$oRoot = $oSource.GetFolder
$oRootItems = $oRoot.Items()

$LoopDeepth = 0
$files=0
$Dirs=0
$TT_Name=False

AdlibRegister("ToolTipUpdate",1000)
SearchRec($oRootItems,$pre)

Func SearchRec($oNextDirs,$_NextPre)
    $LoopDeepth += 1

    Local $oSource
    Local $oSourceName
    Local $oNextRoot
    Local $oNextRootItems

    For $oSource In $oNextDirs
        $NextName = $oSource.name
        $TT_Name=$_NextPre & $NextName
        $NextSize = $oSource.size
        If $oSource.IsFolder Then
            $Dirs+=1
            $oNextRoot = $oSource.GetFolder
            $oNextRootItems = $oNextRoot.Items
            SearchRec($oNextRootItems,$_NextPre & $NextName & "/")
        Else
            $files+=1
            ConsoleWrite("file: " & @TAB & $TT_Name & @TAB & $NextSize & @CRLF)
        EndIf
    Next

    $LoopDeepth -= 1
EndFunc   ;==>SearchRec


Func ToolTipUpdate()
                ToolTip($TT_Name & @CRLF & "Dir Count = " & $Dirs & @CRLF & "File Count = " & $files,MouseGetPos(0)+30,MouseGetPos(1)+30,"Loop Deepth: " & $LoopDeepth)
EndFunc
>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\temp\AndroidCrawler-Autoit-kaputt.au3" /UserParams    
+>15:34:41 Starting AutoIt3Wrapper v.18.708.1148.0 SciTE v.4.1.0.0   Keyboard:00000407  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0407)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\admin.AD\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\admin.AD\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\temp\AndroidCrawler-Autoit-kaputt.au3
+>15:34:41 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\temp\AndroidCrawler-Autoit-kaputt.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
file:   //Galaxy J5 (2016)/Phone/Samsung/Music/Over_the_horizon 0
file:   //Galaxy J5 (2016)/Phone/Android/data/  0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.microsoft.skydrive/cache/current_log  0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.google.android.youtube/files/offline/6D_UEKT9p-7VDC8XVQewEw/streams/3413b53ecc40b3c3  0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.android.providers.media/albumthumbs/1518453668944 0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.google.android.apps.maps/testdata/voice/de_DE.93c5fca3/voice_instructions 0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.google.android.apps.maps/testdata/voice/de_DE3f4b0ca7/voice_instructions_unitless 0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.google.android.apps.maps/cache/diskcache/map_cache    0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.google.android.apps.maps/cache/diskcache/map_cache    0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.google.android.apps.maps/cache/diskcache/map_cache    0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.facebook.appmanager/files/patchedApks/33.com.facebook.system.66964164 0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.facebook.appmanager/files/decompressedApks/86.com.facebook.katana.135360153   0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.google.android.gms/files/gmsnet2  0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.sec.android.app.launcher/cache/homescreenPreview  0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.android.systemui/files/backupwallpapers/original_file_lock    0
file:   //Galaxy J5 (2016)/Phone/Android/data/com.android.systemui/files/backupwallpapers/backup_lock   0

 

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Any suggestions how to get the file SIZE  of files on an Android phone's internal storage System?
 

I've come across a Software called "TreeSize", that's capable to scan the phone's internal and SD Card, but it's randomly crashing, Always showing incomplete results.

 

But at least that SW is showing, that it's possible to get the file sizes.

 

cu, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

use this (refer to my first post) :

For $oSource in $oRootItems
  ConsoleWrite ($oSource.name & "/" & $oSource.IsFolder & "/" & $oRoot.GetDetailsOf ($oSource,2) & @CRLF)
Next

 

Edited by Nine
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...