Skip to main content

Thread: Help with simple bash rename script


hey,
i'm trying learn bit shell scripts , know renaming practical, easy place start. i'm trying rename files of form

1-22bach-stmatthewpassion-part01-22.mp3

form:

#.mp3

# starts @ 1 , goes each additional file.

tried:

code:
#!/bin/bash  j=1  in ls -n;  	rename * $j.mp3   	$j = $((j + 1))  done
but got message saying missing operator before "bach". can help?
thanks!

this seems work:

code:
#!/bin/bash    i=1  file in *.mp3;      mv -- "$file" "$i.mp3"      i=$(($i+1))  done
this prevents dash character being interpreted parameter argument.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] Help with simple bash rename script


Ubuntu

Comments

Popular posts from this blog

CS5 Adobe Media Encoder: Encode failed because the source duration is nil.

cf_sql_integer vs cf_sql_bigint vs cf_sql_int??

localhost/joomla15/administrator doesnt work - Joomla! Forum - community, help and support