Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 181279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:44:07+00:00 2026-05-11T14:44:07+00:00

I had a program work on some images of mine and it returned them

  • 0

I had a program work on some images of mine and it returned them to my directory. funny thing, they’re now all png images instead of gif.

At first i thought it was simple renaming, but I tested with php using createimagefrompng(), which will throw an error if the image is not a valid png file. No errors were returned.

Wheter or not this gives me a 100% accurate result isn’t the issue here, the issue is that I want to rename all those files in a similar way.

Now while I could write a php file to do this for me, I’m wondering how I could do the following in batch or c# or java.

All these files still contain the string ‘.gif’, and I want to remove that. In php it would be as simple as using a foreach-loop, reading the file, using str_replace and then destroying the old one and writing the new one.

I’m kinda stuck as to how I would do this in batch, c# or java, can someone help me here?

Also, I am running windows Vista and I have Powershell 1.0 installed.

Solution 1 – C#:

var files = Directory.GetFiles(@'C:\Downloads\Temp\test\'); foreach (var file in files) {   if(file.Contains('.gif'))   {     string testing = string.Format('{0}.png', Path.GetFileNameWithoutExtension(file.Replace('.gif', '')));     File.Move(file, @'C:\Downloads\Temp\test\'+testing);   } } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:44:08+00:00Added an answer on May 11, 2026 at 2:44 pm

    You could probably do something to the extent of the following in c#

    var files = new DirectoryInfo(@'c:\files').GetFiles(@'*.gif'); foreach (var file in files)     File.Move(file.FullName, string.Format('{0}.gif', Path.GetFileNameWithoutExtension(file.FullName))); 

    or more simply..

    var files = Directory.GetFiles(@'c:\files', @'*.gif'); foreach (var file in files)     File.Move(file, string.Format('{0}.gif', Path.GetFileNameWithoutExtension(file))); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 251k
  • Answers 251k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's mostly irrelevant to your question that your app is… May 13, 2026 at 9:35 am
  • Editorial Team
    Editorial Team added an answer what about zip? you may also try izip from itertools… May 13, 2026 at 9:35 am
  • Editorial Team
    Editorial Team added an answer If it's a field, it will be automatically initialised to… May 13, 2026 at 9:35 am

Related Questions

I dunno if this should go in a Math forum or a Programming forums,
I used F-Spot on Ubuntu to rotate some photos (JPEG files) before I FTPed
Our application is a hybrid Win32 unmanaged application and a .NET 2.0 managed application.
Alright. So I wanted to use a file written in c in c++. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.