Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |
bash [2024/10/18 20:22] – adam | bash [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 |
---|
=== loop over files by type === | |
| |
for i in in *.webm | |
do | |
echo $i | |
done | |
| |
will echo those files. be aware that you're probably going to want to enclose ''$i'' in quotes, e.g.: | |
| |
for i in *.webm | |
do | |
ffmpeg -i "$i" "$i.ogg" | |
done | |
| |
=== mass rename === | |
| |
there’s a package in apt called ''rename''. (not part of the perl distribution; google lead me to some lying liar on the internet. maybe he was right at one time.) | |
| |
so let's say you found a sick-awesome album. so you've done a nice ''yt-dlp --split-chapters https://www.youtube.com/watch?v=aJIDqYZ7qM0''. now you got all these things that are titled like, ''this soundtrack caused me to ACTUALLY DIE and i am a GHOST now (not clickbait) link to my onlyfans in bio, music for men women children best music great music - 001 photograph [aJIDqYZ7qM0].webm'', and a ''002'', and so on. | |
| |
ls | rename -d 's/ \[[^]]*\]\././' | |
| |
pipe ''ls'' to ''rename''. -d for "not the directory, only rename the file", and then do a sed-style replacement string. | |
| |
bonus, you can use ''-n'' or ''--nono'' for "no rename" (or as I like to call it, "not really tho") - i.e., don't actually rename, just do a rename. It spits out a preview. **Be sure to put the -n before the sed pattern.** | |
| |
you can use named capture groups, but you have to do ''\1'', etc. And then the console will bitch at you that you should have done ''$1'', but ''$1'' doesn't work. | |