Rename files with one line command
Solution 1:
You could use rename
...
rename -n 's/^[0-9]+ - //' *
Remove -n
after testing to actually rename the files
Explanation
-
s/old/new/
replaceold
withnew
-
^
start of string -
[0-9]+
some numbers
Solution 2:
bash
parameter expansion to strip off the required portion from start:
for f in *[[:blank:]]*.ogg; do echo mv -i -- "$f" "${f#[[:digit:]]*-[[:blank:]]}"; done
Expanded form:
for f in *[[:blank:]]*.ogg; do
echo mv -i -- "$f" "${f#[[:digit:]]*-[[:blank:]]}"
done
echo
is for dry-running; get rid of it for actual action:
for f in *[[:blank:]]*.ogg; do mv -i -- "$f" "${f#[[:digit:]]*-[[:blank:]]}"; done
Example:
% ls -1
1 - 01 - Hoffnung.ogg
2 - 02 - Familie.ogg
% for f in *[[:blank:]]*.ogg; do mv -i -- "$f" "${f#[[:digit:]]*-[[:blank:]]}"; done
% ls -1
01 - Hoffnung.ogg
02 - Familie.ogg