1. Are you ready for the Galaxy S20? Here is everything we know so far!

Directory of android files

Discussion in 'Android Devices' started by Andy Perrett, Dec 27, 2021.

  1. Andy Perrett

    Andy Perrett Newbie
    Thread Starter

    Can anybody help me with the following.
    I have connected my A6 (phone) to my laptop and would like to get the filenames of a certain directory in a file.
    I tried via the CMD (dos window) on my laptop but the problem is that my A6 has not been assigned a letter as a drive (like c:, d: or e: etc...).
    I thought of using something like this (in dos-window)
    dir c: > drive_c.txt
    But as my A6 has no letter assigned to it I can't figure out how to do this.
    Also some of the directories on my A6 have spaces in the names.
    Curious to see what solutions exist to solve my problem.
    Andy
     



    1. Download the Forums for Android™ app!


      Download

       
  2. Hadron

    Hadron Smoke me a kipper...
    VIP Member

    Android does not use USB mass transfer for file transfer and hence will not be assigned a drive letter. It uses Microsoft's Media Transfer Protocol. I would expect that would just let you browse it using Windows Explorer (provided you enable file transfer mode from the phone), but as I rarely use Windows and never with my phone I can't say how or whether it would work with the command line.
     
  3. iBowToAndroid

    iBowToAndroid Android Enthusiast

    File browsing via CMD would need to be done via USB Debugging
     
    ocnbrze, Dannydet, Hadron and 2 others like this.
  4. Brian706

    Brian706 I like turtles!
    Moderator

    Do you have to use command prompt or was this a workaround you are trying to do? When you plug your device into the PC, it is charge only by default. Check your notification shade for a charging notification. Tap on that and you should get an option to switch to MTP.
     
    ocnbrze, Dannydet and Hadron like this.
  5. Andy Perrett

    Andy Perrett Newbie
    Thread Starter

    Thanks for your replies.
    I do connect my phone via USB to my laptop and I can see the directory structure with all the files on my phone in them on my laptop.
    What I want is a list of all files in a certain directory on my phone, this maybe in text-format.
    Cheers, Andy
     
    ocnbrze and Brian706 like this.
  6. Hadron

    Hadron Smoke me a kipper...
    VIP Member

    On any system with a (pseudo) Unix shell I'd use adb (i.e. USB debugging) to list the contents of a directory and direct the output to a file. Then any old text editor to tidy up to the format I wanted (or write a python script if it's something you will do often). I assume Windows command line would let you direct the output of a command to a file in a similar way, but it's not a system I use much.
     
    ocnbrze, Dannydet and Brian706 like this.
  7. Andy Perrett

    Andy Perrett Newbie
    Thread Starter

    Can you please explain a little more about usb debugging. Not quite sure I know what you mean.
     
  8. Hadron

    Hadron Smoke me a kipper...
    VIP Member

    USB debugging is performed by a program called "adb", which you install on a computer. You then enable USB debugging on the phone (usually via the hidden "developer options" menu, which you unhide by tapping repeatedly on the "build number" in the software information in the system settings - but it's a long time since I ran Android 4.4 so can't guarantee it was already done there). Then if you connect the phone to a computer via a USB cable and USB debugging is enabled on the phone you can use ADB (Android Debug Bridge) to execute a range of commands on the phone.

    The way you do it is by typing adb commands on the command line of your computer. So from the directory you have adb installed in (or from anywhere if you've added that directory to Windows' equivalent of the $PATH, the list of directories that the system looks in when you type a command) you would for example type:

    adb devices

    which should return the serial number of your phone (probably together with some messages about starting an adb daemon). If it does then adb is working, if not you should try to work out why not.

    Then you can get it to list the contents of a directory by typing

    adb shell ls directory

    where the "directory" should be specified using a unix-like format (i.e. "/" rather than "\" between subdirectories). You need to use unix formatting for the directory path because this command is being sent to the android device, and android is based on the linux kernel. The syntax of this command is: "adb" (the program that talks to your phone) "shell" (execute linux shell command on the phone) "ls directory" (the command you want executed). "ls" is the unix command to list the contents of the specified directory - if I remember DOS correctly the equivalent in Windows would be "dir".

    So for example to see the top level of the file system (if it will let you) type

    adb shell ls /

    or the user-accessible part of the internal storage by typing

    adb shell ls /sdcard

    or equivalently

    adb shell ls /storage/emulated/0

    So just put in the path to the directory you want to list the contents of.

    Then if I wanted to write the output to a file, rather than just list it on the screen, I would type

    adb shell ls directory > myfile.txt

    where the ">" is unix shell for "output to the file named here". That's the bit I don't know the Windows equivalent for, but I assume that it exists.
     
    #8 Hadron, Dec 29, 2021
    Last edited: Dec 29, 2021
    Brian706 and Dannydet like this.

Galaxy A6 Forum

The Galaxy A6 release date was May 2018. Features and Specs include a 5.6" inch screen, 16MP camera, 3/4GB RAM, Exynos 7870 Octa processor, and 3000mAh battery.

May 2018
Release Date
0
Reviews
Loading...
Similar Threads - Directory android files
  1. kmarcink
    Replies:
    2
    Views:
    1,343
  2. Taqras
    Replies:
    0
    Views:
    1,636
  3. Jirka Ylönen
    Replies:
    1
    Views:
    1,330
  4. Shagul Hameed
    Replies:
    0
    Views:
    1,089
  5. Youssef Hammad
    Replies:
    0
    Views:
    2,699
  6. Nikolai Savulkin
    Replies:
    1
    Views:
    4,530
  7. marietto2008
    Replies:
    0
    Views:
    2,166
  8. hakelm
    Replies:
    4
    Views:
    578
  9. jamesc123
    Replies:
    0
    Views:
    552
  10. ShalomxPeace
    Replies:
    0
    Views:
    2,174

Share This Page

Loading...