e

I want to make a text file listing all the files in a folder. I would also like to have the listed files sorted by ascending creation date, in apostrophes, and have the word "file" before the file directory.
file '/path/to/file1.wav'
file '/path/to/file2.wav'
file '/path/to/file3.wav'
file '/path/to/file1.wav'
file '/path/to/file2.wav'
file '/path/to/file3.wav'
How do I do this in Termux?
24 Replies
komo
komo3w ago
you can use find, sort, and sed to do that
find -maxdepth 1 -type f -printf "%T@ file '%p'\n" | sort -n | sed 's/^.* file/file/'
find -maxdepth 1 -type f -printf "%T@ file '%p'\n" | sort -n | sed 's/^.* file/file/'
daniel t
daniel tOP3w ago
Alright.
daniel t
daniel tOP3w ago
No description
Mlwls
Mlwls3w ago
e
fisher
fisher3w ago
two simple ways
No description
fisher
fisher3w ago
or if you just want to run file command on all files:
No description
komo
komo3w ago
@TomIO might choke you if you use ls but yeah it's the simple way
TomIO
TomIO3w ago
As long as it's not going in a script it's okay. But you're gonna need to do file $(ls -At) if you're not using Fish.
daniel t
daniel tOP2w ago
No description
fisher
fisher2w ago
as tom said use $() not ()
daniel t
daniel tOP2w ago
This is what I got, and that is not what my files are called.
No description
daniel t
daniel tOP2w ago
The filename for a single file (eg, Set3P5) is "Excepter - Set 3 Part 5: A Buoy Report [240391151].wav" And the list is also not in order of ascending creation date Any fixes for that?
fisher
fisher2w ago
try the second and use " at end not '
daniel t
daniel tOP2w ago
so file '/path/to/file1 name2.wav"?
fisher
fisher2w ago
No description
daniel t
daniel tOP2w ago
oh, oke
daniel t
daniel tOP2w ago
I get nothing
No description
daniel t
daniel tOP2w ago
Actually nevermind. Works now, but the files are put in the reverse order
No description
daniel t
daniel tOP2w ago
But I can just find an online tool to help. A fix is a fix after all, and thanks for the fix.
fisher
fisher2w ago
ls -Art should print in reverse
Mlwls
Mlwls2w ago
pipe it to tac
daniel t
daniel tOP2w ago
Yeah I found a solution already. An online tool, like I said yesterday.
Mlwls
Mlwls2w ago
cool
daniel t
daniel tOP2w ago
And I'm surprised this post did not close, and I did push the button.

Did you find this page helpful?