• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help Directory of android files

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
 
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.
 
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
File browsing via CMD would need to be done via USB Debugging
 
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.
 
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
 
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.
 
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.

Can you please explain a little more about usb debugging. Not quite sure I know what you mean.
 
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.
 
Last edited:
Back
Top Bottom