Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Sep 2007
    Posts
    14

    Default renaming files extention is mp3

    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. #2
    cPanel Partner NOC cPanel Partner NOC Badge
    Join Date
    Mar 2007
    Posts
    3

    Default

    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. #3
    Member
    Join Date
    Sep 2007
    Posts
    14

    Default

    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

Similar Threads & Tags
Similar threads

  1. Password Protect and playing mp3 files
    By jryce in forum New User Questions
    Replies: 5
    Last Post: 04-08-2010, 11:36 AM
  2. Renaming files in filemanager
    By sjh016 in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 04-07-2008, 10:51 AM
  3. Replies: 9
    Last Post: 11-17-2006, 10:17 AM
  4. Exclude mp3 files from backups?
    By drose25 in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 08-21-2006, 02:05 PM
  5. hacking by front page extention
    By kuwaitnt in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 12-01-2004, 03:20 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube