List files recursively?

459 views
Skip to first unread message

moviejimmy

unread,
Nov 26, 2012, 9:51:12 AM11/26/12
to tas...@googlegroups.com
How can I achieve that? The List Files action does not work for my purpose because first, it doesn't do recursive and second, it doesn't support Use Root. I would like all files to be listed in all subdirectories, preferably having one file with full path on each line and then store all file names in a text file.

I tried to do "ls -R /data/data/com.xyz/* > /mnt/sdcard/backup/listfiles.txt" using Run Shell but the format is not what I want.
Tried the "find" command but not similar with it and could not get it to work.

Ultimate goal is to use listfiles.txt in a for loop to copy all files under /data/data/com.xyz to /mnt/sdcard/backup

Please help!

GermainZ

unread,
Nov 26, 2012, 10:49:49 AM11/26/12
to tas...@googlegroups.com
Try the shell command "find"?

TomL

unread,
Nov 26, 2012, 2:17:45 PM11/26/12
to tas...@googlegroups.com
You're going to want to use the linux find command.  Get into a terminal shell and play around with find.  Here are some examples:

find --help

This should tell you all the cmd line options that find supports.

Here's a few examples to get you started:

find /data/data -type f -name \*.txt 

This will print out the full path and filename of any items of type File in any subdir (recursively) of /data/data that matches the pattern *.txt

find /data/data -type f -size +5000k

... will look for files that are larger than 5MB

So for what you want, you can run:

find /data/data/com/.xyz -type f > /mnt/sdcard/backup/listfiles.txt


What was the problem you had with doing :

cp /data/data/com.xyz/* /mnt/sdcard/backup

... directly instead of trying to do it file by file?

Tom

TomL

unread,
Nov 26, 2012, 2:24:35 PM11/26/12
to tas...@googlegroups.com

moviejimmy

unread,
Nov 28, 2012, 2:41:10 AM11/28/12
to tas...@googlegroups.com


What was the problem you had with doing :

cp /data/data/com.xyz/* /mnt/sdcard/backup

... directly instead of trying to do it file by file?

Tom



Many thanks Tom!!! Got your help elsewhere as well. The "-R" parameters did it!

But in addition to copying the files, I also need to change the permissions at the same time for all of the files that get copied. That was why I was thinking about listing out all files using Find. But if you could show me another script that could change file permissions recursively, I would be very very happy!

Message has been deleted

moviejimmy

unread,
Nov 28, 2012, 3:21:15 AM11/28/12
to tas...@googlegroups.com
After copying from Tasker, the owner becomes root and therefore I need to change the permissions so that the original app can update and execute the files.

This should work: chmod -R 777 /data/data/com.xyz ???

But probably better to use chown? How can I find out the appid of any app?

GermainZ

unread,
Nov 28, 2012, 5:43:33 AM11/28/12
to tas...@googlegroups.com
Misc > Test > Package name, but I doubt it'll be useful, since you can dynamically pick the app.
Or you could try pattern matching with the folders in /data/data, but not all apps have something related to their names (e.g. for tasker, you could match *tasker*, but for another app, its package name might not contain its actual name).

TomL

unread,
Nov 28, 2012, 8:01:51 AM11/28/12
to tas...@googlegroups.com
Try adding the option -p (or -P) to the cp command. That should copy the file and dir permissions over to the new items.

Tom
Reply all
Reply to author
Forward
0 new messages