In my .bashrc I have a function which I use to play random videos (not written below, just fyi), and another one for all media files, e.g.:
createmediafiles() { find ~+ -type f -iregex '.*\.\(mp3\|wav\|ogg\|flac\|mp4\|mov\|avi\)' > ~/mediafiles.txt find ~+ -type d -name VIDEO_TS >> ~+/mediafiles.txt } playmediafiles() { while true; do while read -r line; do shuf -n 1 | tee -a ~/played-log.txt | xargs -d "\n" mpv done < ~/mediafiles.txt done } I want to add the VIDEO_TS line to createmediafiles, but in the playmediafiles function I want to add an IF statement, such that if the line shuffled to in mediafiles.txt is a VIDEO_TS then rather than using mpv to play a file, it will do:
tee -a ~/played-log.txt | xargs -d "\n" vlc --fullscreen Piping in mediafiles.txt read the same way as it does with mpv.
How do I throw that in an IF statement with the condition being that the line ends in VIDEO_TS?
playmediafilesis trying to generate a randomised/shuffled list of items to play. Which it sort of does but desperately inefficiently$PWD, and~-is$OLDPWD. I believe it's not standard (it can also be used with a digit to access the other elements of the directory stack in both bash and zsh).~/since that's what the OP uses everywhere else, including to access that file later.createmediafilesfunction was always run from the user's home directory, but it would probably be creating mayhem (or at least unwanted files) if it wasn't.