I ran into a small issue. I would like to copy some files in the precise order they were created.
So the oldest files should be copied first and the newest ones last.
I tried
cp -r $(ls -1t) ./destination
but the files are still not sorted properly. I was thinking, that maybe the system cannot tell them apart properly as the copy process is so fast, that they basically copy simulatiously. Sounds stupid, but for some reason when I use this command, they are not created at the destination in the order they are stored in the source folder.
I was thinking that maybe a sleep or something is needed in between each copy process. So copy the oldest file, sleep one second, copy the next one....
But I am not sure how to get this done properly.
It would be ideal if this could be solved without a script as I want to run this in an Android terminal.
Were the original files created substantially at the same time?
The output of 'ls -lt' is not a simple file list, I would have thought that it should be 'ls -t'.
There are some files that were created within seconds of each other. But most were created hours, days or months apart.
However, this does not seem to matter during the copying process because if I repeat the same command twice, the time of creation of the new files will differ.
So the same command gives different destination file order despite the same original files.
First run:
1
2
5
3
4
6
Second run:
2
3
1
5
6
4
But unlike the cp command, the ls always gives the same result for the original files.
That's why I was thinking of adding some kind of sleep command after each copied file because I'm guessing the problem is not the original sorting, but the speed of file creation. I just don't know how to do it.
OK, I was have trouble getting anywhere. Android itself won't accept all the commands and will simply ignore the sleep command.
So I tried hooking my phone up to a Ubuntu VirtualBox. Unfortunately the VirtualBox is unable to properly mount the phone.
So I now created a live USB stick with Ubuntu on it. I am able to access the phone and all my files.
However, when I execute the commands, I get an error message, that the the "regular file" cannot be created. It creates all the folders/subfolders but is unable to write any files.
I can open the drive manually, create and delete folders etc., so access seems to be there, but why can't it write any files?
Does th system have to be a properly installed Linux? Won't it work on a LiveCD-type system?
Because Android Nougat only allows root users to modify/write timestamps.
It's a known bug in Android 7.0 and won't be fixed until 8.0, which will not be made available to the Samsung S6 edge