Find the answer to your Linux question:
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 21
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Newbie
    Join Date
    Nov 2004
    Location
    New York
    Posts
    150

    I would use find.

    Code:
    find -name "wls*" -exec mv '{}' '{}.mp3' ';'
    I may have screwed up the {} and ; substitutions - they may need a backslash in front, or they may not need to be quoted, etc. But that would do it - you find all files named in that pattern and then execute a command on each.
    \"Nifty News Fifty: When news breaks, we give you the pieces.\" - Sluggy Freelance

  2. #12
    Linux Guru loft306's Avatar
    Join Date
    Oct 2003
    Location
    The DairyLand
    Posts
    1,666
    hmmm there is a rename command? i never knew that....i just use mv (move) probably still will less letters...less typing
    ~Mike ~~~ Forum Rules
    Testing? What's that? If it compiles, it is good, if it boots up, it is perfect. ~ Linus Torvalds
    http://loft306.org

  3. #13
    find -name "wls*" -exec mv '{}' '{}.mp3' ';'
    Cool, that works Thank you.

    hmmm there is a rename command? i never knew that....i just use mv (move) humph.
    rename works grate if you have hundreds of blah.cgi files and you need to rename then to .pl, or things like that. Works grate for most things.... not this one apparently though.

    Thanks for help,

    - Bogdan

  4. $spacer_open
    $spacer_close
  5. #14
    Linux Engineer
    Join Date
    Nov 2004
    Location
    Montreal, Canada
    Posts
    1,267
    Well yes I know it doesnt work as this was only an exemple : i dont like to give THE answer... since finding it yourself you'ld prove much more efficient

    Code:
    #!/bin/bash
    echo "Starting conversion process..."
    for i in wls* ; 
    do
    cp "$i" "$i.mp3" 
    echo "Conversion process completed..."
    done
    CP will make another copy of the file (I recommend if you need the original)
    MV will replace the current filename with the new one
    \"Meditative mind\'s is like a vast ocean... whatever strikes the surface, the bottom stays calm\" - Dalai Lama
    \"Competition ultimatly comes down to one thing... a loser and a winner.\" - Ugo Deschamps

  6. #15
    Ok, that make sense. Sorry about that the ${file##prefix-} part through me off. I was not sure what to do with that. So woud ${file##prefix-} be set to everything after prefix- in the $file variable?

    Thanks for help,

    - Bogdan

  7. #16
    Linux Engineer
    Join Date
    Nov 2004
    Location
    Montreal, Canada
    Posts
    1,267
    actually, this line, remove "##" the "prefix-" from the filename...

    prefix-file1
    prefix-file2
    ~~~~~~~~~~~~~~~~~
    would be
    file1
    file2

    ${file##prefix-}
    $ = file name
    file##prefix-
    file = filename
    ## = remove
    prefix- = what to remove from the fileName
    You understand?
    \"Meditative mind\'s is like a vast ocean... whatever strikes the surface, the bottom stays calm\" - Dalai Lama
    \"Competition ultimatly comes down to one thing... a loser and a winner.\" - Ugo Deschamps

  8. #17
    ahh, I think so. Any good tutorials on what I assume is string manipulations? This looks like useful thing to learn.

    - Bogdan

  9. #18
    Linux Engineer
    Join Date
    Nov 2004
    Location
    Montreal, Canada
    Posts
    1,267
    here's a little something that should get you on the go...
    \"Meditative mind\'s is like a vast ocean... whatever strikes the surface, the bottom stays calm\" - Dalai Lama
    \"Competition ultimatly comes down to one thing... a loser and a winner.\" - Ugo Deschamps

  10. #19
    Linux Engineer
    Join Date
    Nov 2004
    Location
    home
    Posts
    796
    Heh, I never knew about a rename command for Linux. But apparently it's there, I read the man page for it. It's simple to use, too, but not like the one for DOS. Say you have a bunch of .text files, but want to rename them to .txt: 'rename .text .txt *.txt'. The first argument is the original file type, the second is the new one, and the third is all the files you want to rename. So you can't just do 'rename monkey.apple cheese.zebra' and expect it to work, because it won't. Read the man page for more info, it's real short and sweet too.

  11. #20
    Quote Originally Posted by UgoDeschamps View Post
    here's a little something that should get you on the go...
    The link doesn't work for me.
    What activate link does it refer to?
    I get this message.
    System Error: Module is not active
    Unable to find Base Info for Module: guides
    Explanation:

    A module was called that has not yet been activated/installed. Use the activate link in the modules module (Modules->ViewAll) to install modules.

    This topic I find of great interest.
    I am especially interested in removing repetative parts of multiple filenames.
    I am talking about bulk renaming.

    Example is
    abc-two_first.mp3
    abc-two_second.mp3
    abc-two_third.mp3

    How do I remove abc-two_ from all the filenames?
    Is the rename command best for this,or mv?
    Or a combination of both commands put into a script?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •