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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:21:59+00:00 2026-06-15T12:21:59+00:00

I have the below batch that reads data from a text file, the problem

  • 0

I have the below batch that reads data from a text file, the problem is in the inner loop; it should get the lat created file in the destination folder, and it just gets nothing!

here’s my code:

:: Delete Files from folder
@echo off
:: Delete Files from folder
echo y | del "E:\HIS_Data_Consolidation\HIS_Backups\*.bak" 
echo Deleting previous bak files...
set destdir=E:\HIS_Data_Consolidation\HIS_Backups
setlocal
FOR /F "tokens=1,2,3 delims=," %%G IN (clinics.txt) DO (
pushd "%%G"
for /F  "tokens=*" %%a in ('dir *.* /b /a-d /o:e 2^>NUL') do (
set lfile=%%a
)
echo copying "%%G\%lfile%" to "%destdir%" ,,,%%H
copy /y "%%G\%lfile%" "%destdir%
E:
cd "%destdir%
E:\HIS_Data_Consolidation\HIS_Backups\unrar.exe e "%destdir%/%lfile%"
echo y | del "E:\HIS_Data_Consolidation\HIS_Backups\*.rar" 
echo Deleting RAR file...
SET v_test=%lfile%
SET v_result=%v_test:rar=bak%
ren "%v_result%"  "%%I"
echo Ready ...
popd
)
pause

appreciate you help.
thanks.

  • 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-15T12:22:01+00:00Added an answer on June 15, 2026 at 12:22 pm

    If you’are using a set inside for body you’ll need enabledelayedexpansion:
    http://www.robvanderwoude.com/variableexpansion.php

    edit:

    :: Delete Files from folder
    @echo off
    :: Delete Files from folder
    echo y | del "E:\HIS_Data_Consolidation\HIS_Backups\*.bak" 
    echo Deleting previous bak files...
    set destdir=E:\HIS_Data_Consolidation\HIS_Backups
    
    setlocal enabledelayedexpansion
    FOR /F "tokens=1,2,3 delims=," %%G IN (clinics.txt) DO (
        pushd "%%G" 
        for /F  "tokens=*" %%a in ('dir *.* /b /a-d /o:e 2^>NUL') do (
            set lfile=%%a
        )
        echo copying "%%G\!lfile!" to "!destdir!" ,,,%%H
        copy /y "%%G\!lfile!" "!destdir!"
        E:
        cd "!destdir!"
        E:\HIS_Data_Consolidation\HIS_Backups\unrar.exe e "!destdir!/!lfile!"
        echo y | del "E:\HIS_Data_Consolidation\HIS_Backups\*.rar" 
        echo Deleting RAR file...
        SET v_test=!lfile!
        SET v_result=!v_test:rar=bak!
        ren "!v_result!"  "%%I"
        echo Ready ...
        popd
    )
    endlocal
    pause
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the below that is used as a batch file that launches powershell
I am using the batch file example below that I got from batch file
I have written the batch file below, in order to automate the process of
I have an Item Writer as below: <beans:property name=lineAggregator> <beans:bean class=org.springframework.batch.item.file.transform.FormatterLineAggregator> <beans:property name=fieldExtractor> <beans:bean
I have created the below batch file but no success. @ECHO OFF @ECHO Backup
I have a batch file that I need to run within my NSIS installer.
i have a batch(backup.bat)file.in that i have written a command to create a backup
I'm using Windows and have a batch file (contents attached below) where I'm building
I have a batch script that can display two or more colors of text
I'm writing a batch file that runs the below command winscp sftp://username:password@host.com:22 /privatekey=pgp530.ppk 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.