Ok, thanks for the tip. I’m still getting used to Lemmy.
I ended up using
for f in *; do find ./“$f” -type f | sort | tail -n 2 | xargs -n 1 rm; done
and it worked perfectly. For the bonus question, I’m moving the html files from 127 subfolders. They are the only content of the subfolders. I want to prepend an integer to each and copy them to a different folder, so instead of
- folder1/file1
- folder1/file2
- folder2/file1
- folder2/file2
- folder2/file3
I’ll have
- 001file1
- 002file2
- 003file1
- 004file2
- 005file3
Yea, I just came back to say this. Since cp overwrites by default (I tried copying first before trying moving) and each folder has files named index001 index002 etc then then folder where they all go has only ONE of index001.html, ONE of index002.html etc. So I think what I need to do is find each html file, rename it with a unique integer in front of the name, move it to the common folder.