Thread: how to rename all file with program c

  1. #1
    Registered User
    Join Date
    Mar 2019
    Posts
    2

    how to rename all file with program c

    hello I have some trouble for my project. I need to rename all file extension .png to namefile_grey.png.

    example :
    1.png
    2.png
    3.png

    output :
    1_grey.png
    2_grey.png
    3_grey.png

    can anyone solve this problem ??

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,260
    To clarify: are you just trying to modify strings representing filenames? Or are you trying to rename the files in a particular directory that have a ".png" extension? If the latter, is this really meant to be a C program, or is this a practical problem for your actual C project that you're hoping to solve quickly to get it over and done with?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Mar 2019
    Posts
    2
    it will be the second option for me ( " trying to rename the files in a particular directory that have a ".png" extension " ) best regeards

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,260
    Do you know the names of the files in advance? If not, you will need to use OS specific functionality for that, so you should then state the OS this is for, or what cross platform API you might wish to use.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Best way to move / rename a file in C.
    By Spork Schivago in forum C Programming
    Replies: 4
    Last Post: 02-11-2016, 12:38 PM
  2. Replies: 6
    Last Post: 01-26-2009, 08:01 PM
  3. Rename a file
    By Deb in forum C Programming
    Replies: 3
    Last Post: 04-16-2007, 02:43 PM
  4. Rename file problem
    By Emporio in forum C Programming
    Replies: 2
    Last Post: 06-05-2002, 09:36 AM
  5. rename a file on the C drive
    By cyberpuck52 in forum C Programming
    Replies: 3
    Last Post: 01-20-2002, 01:52 PM

Tags for this Thread