The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

renaming files extention is mp3

Discussion in 'General Discussion' started by moobymoo, Feb 13, 2008.

  1. moobymoo

    moobymoo Member

    Joined:
    Sep 7, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    i have a problem in my site.that all for my sites which have ' in there names are not getting download and i m getting a 404 error.i want to know that if there is any command which can rename all files in one folder and sub folders i want to replace "'" with "-"..so kindly help me in it
    i know a command rename "'" "-"* but it only works for current directory i want it to work on current directory and all sub folders in it

    please help me out
     
  2. KaiMeyer

    KaiMeyer Registered
    PartnerNOC

    Joined:
    Mar 15, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    If you're on linux (which it sounds like you are if you are using 'rename'), you can use find.
    # find <folder> -type d

    That will return every subdirectory of <folder> . You can use '.' for 'current directory. You can use the '-exec' flag to execute commands on each folder as it finds them:

    # find . -type d -exec chmod 755 {} \;
    This does a chmod for each folder to 755. {} is the result of the find, and you need to escape the ending semicolon, which tells find that "I'm done executing commands, move on to the next result".

    However, in your case, you probably want to find all the files that end in .mp3 and execute a command on that file. Like so:

    # find . -iname \*.mp3 -type f -exec rename "'" "-"* {} \;

    My suggestion,however, would be to print out your command before you just blast it off:

    # find . -iname \*.mp3 -type f -exec echo rename \"\'\" \"-\" {} \;

    A lot of times I write this output to a file, and then execute the file with sh:

    # find . -iname \*.mp3 -type f -exec echo rename \"\'\" \"-\" {} \; > file.sh
    # sh file.sh

    There's probably another 10 ways to come up with how to do this, but this is how I'd do it.
     
  3. moobymoo

    moobymoo Member

    Joined:
    Sep 7, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    can you please tell me the way that how can i give a directory path from where the command shall seek the files and run it..cause if i run this command then it will problem other users files also
     
Loading...

Share This Page