I know that this project has been silent since long ago, but this script is still the only option to keep timestamps!!!
So far I managed to run it on the pc (using cygwin) because it's not running on my Moto G2 for reading timestams.
Today I decided it was time to try opening a discussion! :)
So, right now the MotoG2 is rooted with Magisk v12, without external busybox but enabled the (basic) internal one.
In the past I MAY (I actually do not remember) have tried using SuperSU and BusyBox from Stericson.
To me it looks like the "stat" cmd I have is not supporting the format used into the script
Here yuo are an output from adb shell:
1|shell@titan_umtsds:/sdcard $
1|shell@titan_umtsds:/sdcard $ su
root@titan_umtsds:/storage/emulated/0 # sh stamps.sh read .
Working on dir: ./
stat: '{}': No such file or directory
stat: '{}': No such file or directory
Just in case, this is the help output of the "stat" available on my phone!
Sorry for the late reply... SF didn't notify me...
Nothing changed:
adb shell
shell@titan_umtsds:/ $ su
root@titan_umtsds:/ # cd sdcard
root@titan_umtsds:/sdcard # sh stamps.sh read /sdcard/
Working on dir: /sdcard//
stat: '{}': No such file or directory
Isn't strange that the "working on" reports the path with a double slash?
Without the trailing slash I got this error
root@titan_umtsds:/sdcard # sh stamps.sh read /sdcard
Missing directory: /sdcard
same error without the starting slash
1|root@titan_umtsds:/sdcard # sh stamps.sh read sdcard/
Missing directory: sdcard/
BTW: I know really a little of Linux...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Could you change the script so it will "echo" the cmd being executed? It could help understanding what is wrong... I know how to do using the MS commands but I do known nothing abouth bash... :-(
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Try going to the sdcard and do find:
cd /sdcard/
find .
And look if it lists all the contents of the sdcard.
What my script does it uses find to list all the files (excluded folders) and on each result of find executes the command stat to get the attributes and then uses sed to sort them and puts everything inside a text file.
Try:
cd /sdcard/
find . > mylist.txt
And see if the txt file contains stuff.
Also check the options of your find (use "find" and "busybox find" alternatively on examples) and see if the option -exec is allowed.
Last edit: dragomerlin 2017-07-15
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
shell@titan_umtsds:/ $ su
root@titan_umtsds:/ # cd /sdcard/
root@titan_umtsds:/sdcard # find .
.
./Android
./Android/media
./Android/media/com.android.providers.media
./Android/media/com.google.android.talk
./Android/media/com.google.android.talk/Notifications
./Android/media/com.google.android.talk/Notifications/hangouts_message.ogg
here you are the system's find help...
1|root@titan_umtsds:/sdcard # find --help
usage: find [-HL] [DIR...] [<options>]
Search directories for matching files.
Default: search "." match all -print all matches.
-H Follow command line symlinks -L Follow all symlinks
Match filters:
-name PATTERN filename with wildcards -iname case insensitive -name
-path PATTERN path name with wildcards -ipath case insensitive -path
-user UNAME belongs to user UNAME -nouser user not in /etc/passwd
-group GROUP belongs to group GROUP -nogroup group not in /etc/group
-perm [-]MODE permissons (-=at least) -prune ignore contents of dir
-size N[c] 512 byte blocks (c=bytes) -xdev stay in this filesystem
-links N hardlink count -atime N accessed N days ago
-ctime N created N days ago -mtime N modified N days ago
-newer FILE newer mtime than FILE -mindepth # at least # dirs down
-depth ignore contents of dir -maxdepth # at most # dirs down
-type [bcdflps] (block, char, dir, file, symlink, pipe, socket)
Numbers N may be prefixed by a - (less than) or + (greater than):
Combine matches with:
!, -a, -o, ( ) not, and, or, group expressions
Actions:
-print Print match with newline -print0 Print match with null
-exec Run command with path -execdir Run command in file's dir
-ok Ask before exec -okdir Ask before execdir
Commands substitute "{}" with matched file. End with ";" to run each file,
or "+" (next argument after "{}") to collect and run with multiple files.
...and this is busybox's find help
root@titan_umtsds:/sdcard # busybox find --help
BusyBox v1.26.2-Stericson (2017-01-14 16:15:58 PST) multi-call binary.
Usage: find [-HL] [PATH]... [OPTIONS] [ACTIONS]
Search for files and perform actions on them.
First failed action stops processing of current file.
Defaults: PATH is current directory, action is '-print'
-L,-follow Follow symlinks
-H ...on command line only
-xdev Don't descend directories on other filesystems
-maxdepth N Descend at most N levels. -maxdepth 0 applies
actions to command line arguments only
-mindepth N Don't act on first N levels
-depth Act on directory *after* traversing it
Actions:
( ACTIONS ) Group actions for -o / -a
! ACT Invert ACT's success/failure
ACT1 [-a] ACT2 If ACT1 fails, stop, else do ACT2
ACT1 -o ACT2 If ACT1 succeeds, stop, else do ACT2
Note: -a has higher priority than -o
-name PATTERN Match file name (w/o directory name) to PATTERN
-iname PATTERN Case insensitive -name
-path PATTERN Match path to PATTERN
-ipath PATTERN Case insensitive -path
-regex PATTERN Match path to regex PATTERN
-type X File type is X (one of: f,d,l,b,c,...)
-perm MASK At least one mask bit (+MASK), all bits (-MASK),
or exactly MASK bits are set in file's mode
-mtime DAYS mtime is greater than (+N), less than (-N),
or exactly N days in the past
-mmin MINS mtime is greater than (+N), less than (-N),
or exactly N minutes in the past
-newer FILE mtime is more recent than FILE's
-inum N File has inode number N
-user NAME/ID File is owned by given user
-group NAME/ID File is owned by given group
-size N[bck] File size is N (c:bytes,k:kbytes,b:512 bytes(def.))
+/-N: file size is bigger/smaller than N
-links N Number of links is greater than (+N), less than (-N),
or exactly N
-prune If current file is directory, don't descend into it
If none of the following actions is specified, -print is assumed
-print Print file name
-print0 Print file name, NUL terminated
-exec CMD ARG ; Run CMD with all instances of {} replaced by
file name. Fails if CMD exits with nonzero
-exec CMD ARG + Run CMD with {} replaced by list of file names
-delete Delete current file/directory. Turns on -depth option
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
130|root@titan_umtsds:/sdcard # stat -c %y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
2017-05-25 15:37:43.000000000
root@titan_umtsds:/sdcard # stat -c %n "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
Android/media/com.google.android.talk/Notifications/hangouts_message.ogg
root@titan_umtsds:/sdcard # stat -c %Y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
1495719463
...the busybox's stat...
root@titan_umtsds:/sdcard # busybox stat -c %y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
2017-05-25 13:37:43.000000000
root@titan_umtsds:/sdcard # busybox stat -c %n "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
Android/media/com.google.android.talk/Notifications/hangouts_message.ogg
root@titan_umtsds:/sdcard # busybox stat -c %Y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
1495719463
...and the last test; it left the input open, I had to press ctrl+c to go back to the prompt...
root@titan_umtsds:/sdcard#busyboxfindAndroid/media/com.google.android.talk/Notifications/hangouts_message.ogg-typeedia/com.google.android.talk/Notifications/hangouts_message.ogg-typef-execsh-c'busybox stat -c %n s_message.ogg -type f -exec sh -c 'busyboxstat-c%n"{}"' \; -exec busybox stat -c %Y "{}" \; -exec s %n "{}" '\;-execbusyboxstat-c%Y"{}"\;-execsh-c'busybox stat -c %y "{}" | sed -e 's/-//g' | ec sh -c 'busyboxstat-c%y"{}"|sed-e's/-//g'|sed-e's/://g'|sed-e"s/ //g"|cut-d'.'-f1|sed"s/./.&/13"'\;<Android/media/com.google.android.talk/Notifications/hangouts_message.ogg1495719463^C
Ciao!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi hope you can understand the following... I have added a "set -x" and this is the output, but only for the first iteration... probably I should put another "set -x" inside the last (very complex) statement!
with v24 script
root@titan_umtsds:/sdcard # sh stamps-v24.sh read .
+ >/dev/null
+ 2>&1
+ command -v find
+ >/dev/null
+ 2>&1
+ command -v sed
+ >/dev/null
+ 2>&1
+ command -v ps
+ cname=0
+ cdate=0
+ '[' read '!=' read ']'
+ sed -e 's,/\+$,,'
+ echo .
+ WDIR=./
+ echo 'Working on dir: ./'
Working on dir: ./
+ '[' read '=' read ']'
+ rm timestamps.txt
+ >>timestamps.txt
+ cd ./
+ find . -type f -exec sh -c 'stat -c %n "{}" ' ';' -exec stat -c %Y {} ';' -exec sh -c 'stat -c %y "{}" | sed -e s/-//g | sed -e s/://g | sed -e "s/ //g" | cut -d . -f1 | sed "s/./.&/13" ' ';'
stat: '{}': No such file or directory
stat: '{}': No such file or directory
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok try stamps-v2.7.sh should work to read and write. To check a single file just edit timestamps.txt and leave the 3 lines for a file you want to test with, for example put a file in sdcard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
BTW, I have compared v2.4 with v2.7 and found you have delete every references to "busybox", not only in comments but also in code for "write". Is that correct or a side-effect from testing? :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
root@titan_umtsds:/sdcard # sh stamps.sh write backups/
Working on dir: backups//
touch: invalid date '2017-07-12 14:17:26.000000000'
root@titan_umtsds:/sdcard #
Same error with v2.4
Last edit: Giangi 2017-07-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
root@titan_umtsds:/ # echo -e "house\nhouse\nhouse\nhouse"
house
house
house
house
...the second (BTW, inside the "adb shell" launched from Win10 command I cannot type the tilde ~! I had to launch adb shell from Cygwin but I do not like it because I cannot have the same cursor's movements and copy&paste as from the Win10 command...) gives a sed's error...
I know that this project has been silent since long ago, but this script is still the only option to keep timestamps!!!
So far I managed to run it on the pc (using cygwin) because it's not running on my Moto G2 for reading timestams.
Today I decided it was time to try opening a discussion! :)
So, right now the MotoG2 is rooted with Magisk v12, without external busybox but enabled the (basic) internal one.
In the past I MAY (I actually do not remember) have tried using SuperSU and BusyBox from Stericson.
To me it looks like the "stat" cmd I have is not supporting the format used into the script
Here yuo are an output from adb shell:
Just in case, this is the help output of the "stat" available on my phone!
What happens if you do
sh stamps.sh read /sdcard/
Sorry for the late reply... SF didn't notify me...
Nothing changed:
Isn't strange that the "working on" reports the path with a double slash?
Without the trailing slash I got this error
same error without the starting slash
BTW: I know really a little of Linux...
The double dash does not affect. The script adds a dash always in case you put only the name so it always has a dash at least at the end.
Try the newer version stamps-v2.5-busybox_stat.sh wich uses the stat from busybox instead of the default from android.
Hi,
nothing changed... :-(
I have used this https://play.google.com/store/apps/details?id=stericson.busybox
Could you change the script so it will "echo" the cmd being executed? It could help understanding what is wrong... I know how to do using the MS commands but I do known nothing abouth bash... :-(
BTW, this is the new stat currently installed help
Try the newer version which uses busybox find instead of the find included in the smartphone.
https://sourceforge.net/projects/androidtimestampkeeper/files/stamps-v2.6-busybox_stat_find.sh/download
Try going to the sdcard and do find:
cd /sdcard/
find .
And look if it lists all the contents of the sdcard.
What my script does it uses find to list all the files (excluded folders) and on each result of find executes the command stat to get the attributes and then uses sed to sort them and puts everything inside a text file.
Try:
cd /sdcard/
find . > mylist.txt
And see if the txt file contains stuff.
Also check the options of your find (use "find" and "busybox find" alternatively on examples) and see if the option -exec is allowed.
Last edit: dragomerlin 2017-07-15
Yes, it finds something...
here you are the system's find help...
...and this is busybox's find help
cd /sdcard/
stat -c %y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
stat -c %n "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
stat -c %Y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
busybox stat -c %y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
busybox stat -c %n "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
busybox stat -c %Y "Android/media/com.google.android.talk/Notifications/hangouts_message.ogg"
busybox find Android/media/com.google.android.talk/Notifications/hangouts_message.ogg -type f -exec sh -c 'busybox stat -c %n "{}" ' \; -exec busybox stat -c %Y "{}" \; -exec sh -c 'busybox stat -c %y "{}" | sed -e 's/-//g' | sed -e 's/://g' | sed -e "s/ //g" | cut -d '.' -f1 | sed "s/./.&/13" ' \;
ok, here you are the first three stat...
...the busybox's stat...
...and the last test; it left the input open, I had to press ctrl+c to go back to the prompt...
Ciao!
BTW, v2.6 has worked but only for the first file in "read" mode!! :-)
I had to ctrl+c to stop and the file had only one file inside...
Last edit: Giangi 2017-07-25
This is what I get with Cygwin:
Looks like your commands are working with and without busybox. Use the code icon to post better. What is the problem now, does not work?
As I wrote, v26 it works, but only for the first file and then it hung. The generated file, after about 10 minutes, contains only one entry...
Hi hope you can understand the following... I have added a "set -x" and this is the output, but only for the first iteration... probably I should put another "set -x" inside the last (very complex) statement!
with v24 script
...with v25...
...with v26...
Ok try only read with the script "stamps-test-1.sh". Don't use write is not compatible.
oh YES! It worked! :-) Here you are the first lines...
This is the ls output, I bet the time is GMT (my computer is on CEST)
Ok try stamps-v2.7.sh should work to read and write. To check a single file just edit timestamps.txt and leave the 3 lines for a file you want to test with, for example put a file in sdcard.
The read has worked but I got this error at the end
Now I will try the write.
BTW, I have compared v2.4 with v2.7 and found you have delete every references to "busybox", not only in comments but also in code for "write". Is that correct or a side-effect from testing? :)
The write operation has failed with v2.7 :(
Same error with v2.4
Last edit: Giangi 2017-07-27
Here you are the system's touch help
...and this the busybox's one
Could it be that the parameter to use is -d since mine stat is formatting both date and time?
Last edit: Giangi 2017-07-27
I have modified timestamps.txt removing the separators and now the v2.7 "write" has restored the date I have changed! :-)
Try these commands and see if work:
Another:
This the same result as before:
Last edit: dragomerlin 2017-07-27
Here you are the first...
...the second (BTW, inside the "adb shell" launched from Win10 command I cannot type the tilde ~! I had to launch adb shell from Cygwin but I do not like it because I cannot have the same cursor's movements and copy&paste as from the Win10 command...) gives a sed's error...
...the third too gives a sed's error...