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 6928545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:12:07+00:00 2026-05-27T11:12:07+00:00

We have a program that take specific XML files and imports them, then changes

  • 0

We have a program that take specific XML files and imports them, then changes the file from .xml to .tmp. Once it turns to .tmp we can delete the file.

Occasionally what happens is the XML file doesn’t import properly, in which case it gets renamed from .xml to .bad and the file has to be manually adjusted (could be an improper xml file or whatever). What we’ve discovered is that roughly 90% of the time if you rename the file back to .xml it imports fine.

I’ve created a batch script to run every couple of minutes that automatically deletes the .tmp files. What I also want to do is add something to the script that renames .bad file to .xml in order to let the program try and import it again. That will cover the 90%.

In order to cover the last 10%, I’d like to set it up so that after about 10 minutes, it no longer tries to rename the file .bad back to .xml (based on the creation date).

So far, what I have is the script to delete the .tmp files:

forfiles -p "C:\path\to\xml" -m *.tmp -c "cmd /c del @PATH"

And I have the script to rename .bad to .xml:

forfiles -p "C:\path\to\xml" -m *.bad -c "cmd /c ren *.bad *.xml"

How do I tell the 2nd command to do it only for files whose creation date (not last modified date) was less than 10 minutes ago?

Updated:

Here’s the full solution (thanks to jon Z for pointing me in the right direction):

powershell.exe -command "get-childitem 'path\to\xml' -filter *.tmp | Remove-Item"

powershell.exe -command "get-childitem 'path\to\xml' -filter *.bad | where-object {$_.creationtime -gt (get-date).addminutes(-8)} | foreach-object {move-item $_.fullname ($_.fullname-replace '.bad','.xml')}"
  • 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. Editorial Team
    Editorial Team
    2026-05-27T11:12:07+00:00Added an answer on May 27, 2026 at 11:12 am

    If using powershell instead of cmd is an option, you could do the following:

    to delete the files:

    get-childitem c:\path\to\xml -filter *.tmp | remove-item
    

    to rename the .bad to .xml

    get-childitem c:\path\to\xml -filter *.bad |  where-object {$_.creationtime -gt (get-date).addminutes(-10)} | foreach-object {move-item $_.fullname ($_.fullname -replace '.bad','.xml')}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that is going to take a password as input and
I have a program that uses the mt19937 random number generator from boost::random. I
I have a program that spits out an Excel workbook in Excel 2003 XML
I have a program that runs osql.exe from microsoft sql server tools directory and
I have a program that is stored in program files folder. I created windows
I have an app that aggregates apps from the app store for a specific
I'm writing a program that needs to take input from an XBox 360 controller.
I have program that has a variable that should never change. However, somehow, it
I have program that runs fast enough. I want to see the number of
I have a program that spits out both standard error and standard out, and

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.