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

  • SEARCH
  • Home
  • 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

Related Questions

For some reason, I can't get this program to work. I've had other CS
I have had some problems earlier which caused my program to crash in all
I had written a program in Python 3, but now want to convert it
We had our own custom logger in a C# program and now are trying
I'm working on some big multi threaded project, now yesterday I had a deadlock
I'm using Fedora and I have had some issues to get javac to work
I had a Java program that I run thousand times based on a loop
This question has baffled myself and my cohorts. In the program I had written
I had earlier written a program in java which takes in as input a
i had a question in my program. When I pass the 3D int array

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.