#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Location
    Bokaro Steel City, India
    Posts
    4
    Rep Power
    0

    Question How to rename multiple files in a folder at once?


    Hi friends!
    I have a folder containing a lot of songs, all in mp3 format. I want to create a program to rename them at once using a definite pattern.

    Right now I only know how to rename a file using the rename function.

    Please guide me in the right direction. I just want to know how to read a folder / directory for the files contained in it. I do not want you to code the whole program. Just guide me by naming some functions that are useful in this case.

    Any help is appreciated! :)
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    71
    Rep Power
    2
    Which operating system are you using?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Location
    Bokaro Steel City, India
    Posts
    4
    Rep Power
    0
    Microsoft Windows XP
    (32 bits, SP2)

    Also, I am using MVC++ 6.0.
    Last edited by TheAliveWinner; October 22nd, 2012 at 12:34 AM. Reason: Provided incorrect info by mistake! :(
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,381
    Rep Power
    1871
    How to get a list of files

    Given a filename in a string like say
    std::string filename = "file01.mp3";
    do you know enough string operations to create
    std::string new_filename = "file - 01.mp3";

    Then you just do
    rename( filename.c_str(), new_filename.c_str() );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,850
    Rep Power
    481
    install cygwin, use bash

    $ for f in *.mpg ; do echo mv $f ${f!} ; done

    when you get ! correct either remove echo or pipe the works to bash.
    [code]Code tags[/code] are essential for python code and Makefiles!
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Location
    Bokaro Steel City, India
    Posts
    4
    Rep Power
    0
    Thank you, friends! :)

IMN logo majestic logo threadwatch logo seochat tools logo