Hi, it's TJ the "here's a shell script" guy saying "Here's a shell script".
There are a few options. The first is ls
(that's a lowercase LS
).
For example, if I type:
ls ~/Music/
then I will get this back as an answer:
Audio Hijack Music ffatp
Now, as it turns out, those 3 things are actually folders not files, and inside those folders are files (and additional folders).
If we want to keep going inside those folders, we need to use the -R
flag to ls
to recursively list all of the folders. While we're at it, we might want to use -F
which also tries to give some indication what each entry is, such as a /
at the end of folder names:
If I do ls -FR ~/Music
then
Audio Hijack/
Music/
ffatp/
/Volumes/tjluoma/Music/Audio Hijack:
ATP.fm-2020-02-26-at-20-58.mp3
/Volumes/tjluoma/Music/Music:
Media.localized/
Music Library.musiclibrary/
/Volumes/tjluoma/Music/Music/Media.localized:
Automatically Add to Music.localized/
Downloads-Music/
Steven Curtis Chapman/
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized:
/Volumes/tjluoma/Music/Music/Media.localized/Downloads-Music:
/Volumes/tjluoma/Music/Music/Media.localized/Steven Curtis Chapman:
Live from Sweetwater Studios Sessions/
/Volumes/tjluoma/Music/Music/Media.localized/Steven Curtis Chapman/Live from Sweetwater Studios Sessions:
I Will Be Here.mp3
/Volumes/tjluoma/Music/Music/Music Library.musiclibrary:
Application.musicdb
Extras.itdb
Genius.itdb
Library Preferences.musicdb
Library.musicdb
Preferences.plist
sentinel
/Volumes/tjluoma/Music/ffatp:
ATP 2020-02-26.mp3
That‘s not bad but I think what you really want is better handled by find
because with find
you can say “Show me only files, not folders or anything else, and show me the full path to each file.”
The way that you do that is like this:
find ~/Music -type f -print
(-type f
means “just files”)
If I do that then I get something that looks like this:
/Volumes/tjluoma/Music/Music/Media.localized/.Media Preferences.plist
/Volumes/tjluoma/Music/Music/Media.localized/.localized/id.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/es.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/no.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/zh_TW.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/fi.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/ru.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/en.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/es_419.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/he.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/uk.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/fr_CA.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/nl.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/de.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/ja.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/sk.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/hr.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/el.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/th.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/zh_CN.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/cs.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/sv.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/pl.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/zh_HK.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/en_GB.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/en_AU.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/da.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/fr.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/ro.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/pt.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/pt_PT.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/ms.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/ko.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/hu.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/hi.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/tr.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/vi.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/ca.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/ar.strings
/Volumes/tjluoma/Music/Music/Media.localized/.localized/it.strings
/Volumes/tjluoma/Music/Music/Media.localized/Steven Curtis Chapman/Live from Sweetwater Studios Sessions/I Will Be Here.mp3
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/id.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/es.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/no.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/zh_TW.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/fi.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/ru.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/en.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/es_419.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/he.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/uk.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/fr_CA.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/nl.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/de.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/ja.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/sk.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/hr.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/el.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/th.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/zh_CN.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/cs.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/sv.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/pl.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/zh_HK.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/en_GB.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/en_AU.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/da.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/fr.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/ro.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/pt.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/pt_PT.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/ms.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/ko.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/hu.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/hi.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/tr.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/vi.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/ca.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/ar.strings
/Volumes/tjluoma/Music/Music/Media.localized/Automatically Add to Music.localized/.localized/it.strings
/Volumes/tjluoma/Music/Music/.DS_Store
/Volumes/tjluoma/Music/Music/Music Library.musiclibrary/Application.musicdb
/Volumes/tjluoma/Music/Music/Music Library.musiclibrary/Extras.itdb
/Volumes/tjluoma/Music/Music/Music Library.musiclibrary/sentinel
/Volumes/tjluoma/Music/Music/Music Library.musiclibrary/Library.musicdb
/Volumes/tjluoma/Music/Music/Music Library.musiclibrary/Genius.itdb
/Volumes/tjluoma/Music/Music/Music Library.musiclibrary/Library Preferences.musicdb
/Volumes/tjluoma/Music/Music/Music Library.musiclibrary/Preferences.plist
/Volumes/tjluoma/Music/ffatp/ATP 2020-02-26.mp3
/Volumes/tjluoma/Music/.localized
/Volumes/tjluoma/Music/Audio Hijack/.DS_Store
/Volumes/tjluoma/Music/Audio Hijack/ATP.fm-2020-02-26-at-20-58.mp3
If you want more detail about each file, use:
find ~/Music -type f -ls
(change -print
to -ls
).
If you want the list to be sorted alphabetically, use:
find ~/Music -type f -print | sort -f
If you want the list to be sorted alphabetically and include a blank line between each line (which can make it much easier to read if you have a lot of long times), use:
find ~/Music -type f -print | sort -f | sed G
If you want all of that, and you want it to save the output to a file, try this:
#!/usr/bin/env zsh -f
PATH='/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin'
zmodload zsh/datetime
TIME=$(strftime "%Y-%m-%d--%H.%M.%S" "$EPOCHSECONDS")
find "$HOME/Music" -type f -print | sort -f | sed G \
> "$HOME/Desktop/Music-File-List-as-of-$TIME.txt"
exit 0
Every time that script runs, the list of files will be saved to your ~/Desktop/ but you can change that by changing $HOME/Desktop/
($HOME
is just another way of referring to your home folder where all of your files appear in Finder.) For example you could change it to $HOME/Dropbox/
if you wanted it stored in Dropbox instead. Just make sure the folder exists.
You could copy/paste that script into Keyboard Maestro and have it run every Sunday at 12:30 p.m. (or whenever) using the Time of Day
trigger that has already been suggested.
That's what this macro does.
Index-Files-in-Music-Folder.kmmacros (2.3 KB)
It does Sunday and Wednesday, just because. You can set it to whatever times/days you'd like.
Let me know if you have questions/problems/etc.