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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:06:13+00:00 2026-06-07T11:06:13+00:00

Found the same question here.. I am trying to use the code but for

  • 0

Found the same question here.. I am trying to use the code but for my data. I am in no way a programmer.. I can take almost any code and make it work for me however.

How to code a batch file to copy and rename the most recently dated file?

Here is my

 @echo on
 setLocal DisableDelayedExpansion
 pushd  N:\
 setLocal EnableDelayedExpansion

 for /f "tokens=* delims= " %%G in ('dir/b/od') do (set newest=%%G)

 copy %newest% G:\Server_Files\AMI_DATA\TEXT_FILES\NewFile.csv

 PAUSE
 POPD

And the results…

C:\Documents and Settings\belcherj\Desktop\AMI_BATCH>setLocal DisableDelayedExpa
nsion

C:\Documents and Settings\belcherj\Desktop\AMI_BATCH>pushd  N:\

N:\>setLocal EnableDelayedExpansion

N:\>for /F "tokens=* delims= " %G in ('dir/b/od') do (set newest=%G )

N:\>(set newest=System Blink Count__2012-06-27 01_00_46.csv )

N:\>(set newest=System Blink Count__2012-06-28 01_00_32.csv )

N:\>(set newest=System Blink Count__2012-06-29 01_00_33.csv )

N:\>(set newest=System Blink Count__2012-06-30 01_00_42.csv )

N:\>(set newest=System Blink Count__2012-07-01 01_00_32.csv )

N:\>(set newest=System Blink Count__2012-07-02 01_00_31.csv )

N:\>(set newest=System Blink Count__2012-07-03 01_00_29.csv )

N:\>(set newest=System Blink Count__2012-07-04 01_00_39.csv )

N:\>(set newest=System Blink Count__2012-07-05 01_00_34.csv )

N:\>(set newest=System Blink Count__2012-07-06 01_00_31.csv )

N:\>(set newest=System Blink Count__2012-07-07 01_00_32.csv )

N:\>(set newest=System Blink Count__2012-07-08 01_00_30.csv )

N:\>(set newest=System Blink Count__2012-07-09 01_00_40.csv )

N:\>(set newest=System Blink Count__2012-07-10 01_00_29.csv )

N:\>(set newest=System Blink Count__2012-07-11 01_00_44.csv )

N:\>(set newest=System Blink Count__2012-07-12 01_00_34.csv )

N:\>copy System Blink Count__2012-07-12 01_00_34.csv G:\Server_Files\AMI_DATA\TE
XT_FILES\NewFile.csv
The system cannot find the file specified.

N:\>PAUSE
Press any key to continue . . .

I think it has something to do with the spaces in the file names.. I tried some other code i found and it gave the same results. Im close just need a little push.
Thanks for you time and help.

  • 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-06-07T11:06:15+00:00Added an answer on June 7, 2026 at 11:06 am

    This should work

    @echo off
    cd /d N:\
    for /f "tokens=*" %%a in ('dir /b /od') do set newest=%%a
    echo f| xcopy "%newest%" G:\Server_Files\AMI_DATA\TEXT_FILES\NewFile.csv
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use inheritance in JavaScript here, and I found problem having array
I found this question here: OLEDB v/s ODBC Which gave me more information, but
I've run into the same problem as found in this question . However, I
I found myself instantiating the same objects in numerous tests, so I'm trying to
I've found a number of posts on this same subject ( here's one) and
The SSE shift instructions I have found can only shift by the same amount
I'm using Jquery Draggable Collision ( found here ) and I am trying to
I'm trying to use the cameras LED flashlight in a widget. I've found several
below is a code example and the question, please note that I can NOT
I'm trying to use the built-in Internal.Transformation.Filename.Directory variable. I take as an example a

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.