Sponsored Content
Full Discussion: Bash: renaming file issues.
Top Forums Shell Programming and Scripting Bash: renaming file issues. Post 302599849 by josco1982 on Sunday 19th of February 2012 12:17:37 AM
Old 02-19-2012
Bash: renaming file issues.

Hi, i want to rename a group of directories and files of my music, some items are like this:

[Artist] - [Album], for directories.
[Artist] - [Song title], for files.

I want to do something like this:

[Album], for directories.
[Song title], for files.

This is my code:
Code:
#!/bin/bash
for fname in *.mp3; do
    echo item: $fname
    mv -f $fname ${fname#*-}
done

This is a reduced list of my output:
Code:
user@intel-computer:~/Music/tmp$ ./trim_filename.sh
item: 01 - Bad Romance.mp3
mv: target `Romance.mp3' is not a directory
item: 01 - Just Dance.mp3
mv: target `Dance.mp3' is not a directory
item: 02 - Alejandro.mp3
mv: target `Alejandro.mp3' is not a directory
item: 02 - LoveGame.mp3
mv: target `LoveGame.mp3' is not a directory
item: 03 - Paparazzi.mp3
mv: target `Paparazzi.mp3' is not a directory
item: 04 - Poker Face.mp3
mv: target `Face.mp3' is not a directory
item: 05 - Dance In the Dark.mp3
mv: target `Dark.mp3' is not a directory
item: 06 - Telephone.mp3
mv: target `Telephone.mp3' is not a directory
user@intel-computer:~/Music/tmp$

Can anyone throw some pointers for this?
Thank you for your kind attention.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Renaming files in a bash script

I'm doing a short batch script to compile po files producing output binary mo files. The compilation command is: msgfmt -o file.mo file.po so in order to compile I am appending .mo to the varible in a loop. It goes something like this: for i in `find . -name "*.po"` do echo... (2 Replies)
Discussion started by: Breen
2 Replies

2. Shell Programming and Scripting

Bash script issues

Hi. The below part of my bash script kicks out the following error message: $ ./extract_eod_report_stats_new.sh 2010-04-23 ./extract_eod_report_stats_new.sh: line 204: syntax error near unexpected token `(' ./extract_eod_report_stats_new.sh: line 204: `TRANSACTIONS_RECEIVED_TOP=`grep... (6 Replies)
Discussion started by: Peter.Lovell
6 Replies

3. Shell Programming and Scripting

Bash Script issues

So what i am trying to do is write a script that takes in any number of scrambeled words and unscrambles them. I have already addressed the issues of partial matches, exits silently if there are no matches, and finds words regardless of case that they were input. but while trying to get it so... (3 Replies)
Discussion started by: alindner
3 Replies

4. Shell Programming and Scripting

BASH Batch renaming insert additional zero into filename

Hi all, Wondering how this could be accomplished........ a directory contains sequentially numbered files from fw01 to fw999. How would I insert an additional zero so that the directory lists these files in a proper manner? (i.e. all double digit files from fw01 to fw99 would become... (3 Replies)
Discussion started by: putter1900
3 Replies

5. Shell Programming and Scripting

Unix bash script (mv issues);

Hey guys, I've registered here as I need urgent help. This is assignment for school and as you can see below I've completed the work. I'm simply stuck on one area. :wall: This script takes the first parameter (which is to be the new extension) and each parameter after that is a file... (1 Reply)
Discussion started by: Cynosure
1 Replies

6. Shell Programming and Scripting

Bash Script Issues (If statement for file copying)

Writing a bash script for use with Geektool, pulls the battery info, and shuffles images around so that an Image geeklet can display the correct expression as the desktop background. (Eventually I intend to make it more intricate, based on more variables, and add more expressions) I'm extremely... (1 Reply)
Discussion started by: The_Ardly374
1 Replies

7. Shell Programming and Scripting

Bash Case Issues..

Hi, I'm having some trouble with using "case...esac" in Bash. I've googled it and am stuggling to understand the syntax and how to do certain things. Firstly, I want to be able to choose a case based on a variable number For example, I have in my code a place where a user can enter... (2 Replies)
Discussion started by: Ste_Moore01
2 Replies

8. Shell Programming and Scripting

Bash/cron issues

Hi all, I am trying to run a cronjob to push my files to my git repo once a week and output a prompt to a logfile, my script works fine if I invoke it manually but my cronjob wont run for some reason, I have sourced the file, and restarted my Mac to no avail, right now I believe I have the cronjob... (8 Replies)
Discussion started by: gmenfan83
8 Replies

9. Shell Programming and Scripting

Recursive File Renaming & Natural Sorting (Bash)

NB! I have already started a thread on this subject on ComputerHope (with the thread title "Recursive File Renaming & Logical Sorting"). However, on ComputerHope they are perhaps more specialized in Windows Command Prompt, and not that much in shell scripts for Bash (I guess). I have a bulk... (1 Reply)
Discussion started by: JewzeyfGhewbelz
1 Replies

10. Shell Programming and Scripting

Need help in batch renaming files with bash shell script.

I have some 50+ files in the following format : abcd_vish_running_ZEBRA_20140818.dat_08-14-2014_23:08:23 abcd_vish_running_ZEB-RA_20140818.dat_08-14-2014_23:08:35 abcd_vish_running_ZEB_RA_20140818.dat_08-14-2014_23:08:37 abcd_vish_running_RI-NG_20140818.dat_08-14-2014_23:08:42... (5 Replies)
Discussion started by: SriRamKrish
5 Replies
Audio::MPD::Common::Item::Song(3pm)			User Contributed Perl Documentation		       Audio::MPD::Common::Item::Song(3pm)

NAME
Audio::MPD::Common::Item::Song - a song object with some audio tags VERSION
version 1.120881 DESCRIPTION
Audio::MPD::Common::Item::Song is more a placeholder with some attributes. Those attributes are taken from the song tags, so some of them can be empty depending on the file. The constructor should only be called by Audio::MPD::Common::Item's constructor. ATTRIBUTES
album Album of the song. (format code: %d) artist Artist of the song. (format code: %a) albumartist Artist of the album. (format code: %A) composer Song composer. (format code: %C) date Last modification date of the song. (format code: %M) disc Disc number of the album. This is a string to allow tags such as "1/2". (format code: %D) file Path to the song. Only attribute which will always be defined. (format code: %f) genre Genre of the song. (format code: %g) id Id of the song in MPD's database. (format code: %i) last_modified Last time the song was modified. (format code: %m) name Name of the song (for http streams). (format code: %N) performer Song performer. (format code: %P) pos Position of the song in the playlist. (format code: %p) title Title of the song. (format code: %t) track Track number of the song. (format code: %n) time Length of the song in seconds. (format code: %l) METHODS
as_string my $str = $song->as_string( [$format] ); Return a string representing $song. If $format is specified, use it to format the string. Otherwise, the string returned will be: either "album = track = artist = title" or "artist = title" or "title" or "file" (in this order), depending on the existing tags of the song. The last possibility always exist of course, since it's a path. This method is also used to automatically stringify the $song. WARNING: the format codes are not yet definitive and may be subject to change! AUTHOR
Jerome Quelin COPYRIGHT AND LICENSE
This software is copyright (c) 2007 by Jerome Quelin. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-04-01 Audio::MPD::Common::Item::Song(3pm)
All times are GMT -4. The time now is 12:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy