So my specific problem is I downloaded a few albums of mp3s, that don't have track numbers in their title, so they default to alphabetic sort, which is clearly not ideal. I want to be able to quickly rename them with a terminal command where I use wildcards to sort through the fluff. So I've tried this from a few angles without success, and want some guidance.
On the one hand, I want to try something like mv *someSongN* 01-{reference original name here}
. I am not clear, in the second argument to mv
, how I reference the original file name, but prepended with a 01-
.
The other tack I tried was to create a temporary bash variable, followed by a mv
command. I tested this out by creating a test file without any extension -- touch test
. I found echo
and mv
treat the wildcard differently. So, pretend the test file is the only in the directory beginning te-- ... var=te*; echo $var
returns test
but var=te*; mv $var $var.txt
returns te*.txt
. So what strategy do I use here. I could also do this with a graphical file manager but I've done that before and found it very tiresome.
Do it as a batch process. Create a map file with columns fromName toName, run through a script for renaming.
while read a b; do mv "$a" "$b"; done < filemap
to create filemap, ls and paste
ls -1 > files; paste files files > filemap; rm files
and manually edit the filemap file to add required prefixes.