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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:16:21+00:00 2026-06-06T00:16:21+00:00

A slightly archaic question I’m afraid but here goes: I have a program which

  • 0

A slightly archaic question I’m afraid but here goes:

I have a program which produces some .RAW files in a sequence eg.

Example_1.RAW
Example_2.RAW

This then adds extra significant figures to the number as necessary, eg.

Example_10.RAW
Example_200.RAW

I have a need to convert these file names into numbers for running through a batch processor that then produces more files as outputs. I’ve written a batch file that does the renaming and stores the old and new filenames in a text file, my code is:

@echo off
set i=1
echo Running Batch Rename
for %%f in (*.RAW) do (set file=%%f) & CALL :rename

:rename
echo %i% >>Names.txt
echo %file% >>Names.txt
echo. >>Names.txt
ren %file% %i%.RAW
set /A i+=1

This then renames all my .RAWs as 1.RAW, 2.RAW etc and creates Names.txt with the old and new filenames. Thanks to the way in which DOS processes numbers this does mean that I get a slightly wonky numbering process, ie it will process Ex_1, Ex_10, Ex_100, Ex_101 as 1, 2, 3, 4 which would lead to more work in the post processing of these results in order to get the right results in the right places.

Would it be possible to write another batch file that takes the Names.txt and reverses the process for the output files? So it will take a folder with 1.raw, 1.something, 1.something else, refer to the Names.txt and rename them to Example_1.raw etc?

  • 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-06T00:16:23+00:00Added an answer on June 6, 2026 at 12:16 am

    This should do the job

    @echo off
    set cnt=0
    del Names.txt > nul 2>&1
    echo Running Batch Rename
    for %%f in (*.RAW) do (
        set "file=%%f"
        CALL :renameToNumber
    )
    echo .. Do the jobs ...
    rem ** As sample: copy the file
    copy *.raw *.some
    call :renameBack
    exit /b
    
    :renameToNumber
    set /A cnt+=1
    set "number=00000%cnt%"
    set "number=%number:~-4%"
    (echo %number% %file%) >> Names.txt
    ren "%file%" %number%.RAW
    exit /b
    
    :renameBack
    for /F "tokens=1,*" %%A in (names.txt) DO (
       set "number=%%A"
       set "filename=%%~nB"
       call ren %%number%%.* "%%filename%%_%%number%%.*"
       call echo ren %%number%%.* "%%filename%%_%%number%%.*"
    )
    exit /b
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Slightly broad question here, but here goes I'm trying to call an Oracle stored
Another slightly non-technical question, but I couldn't decide whether to ask here or on
Slightly unusual requirement here, which unfortunately is down to a poor table design a
Question slightly in the abstract... We have a situation where we have a struct
I have a slightly theoretical question that I want to clear up before I
I have a couple slightly modified / non-traditional setups for feedforward neural networks which
I have a slightly complex problem here. I need to show to the client
This is a slightly tricky question. I am using NSDateFormatter on the iPhone but
Slightly unorthodox question here: I'm currently trying to break an Apache with a handful
A slightly tricky SQL question (we are running SQL server 2000). I have the

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.