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

  • Home
  • SEARCH
  • 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 6941553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:54:02+00:00 2026-05-27T12:54:02+00:00

I have a text file with a list of file paths. For example, they

  • 0

I have a text file with a list of file paths.

For example, they generally look like this:
F:\datapath\some more path\path\path\thefile.ext

I’m trying to feed it into hobocopy, but hobocopy doesn’t like file paths with trailing slashes. So, I’m trying to extract the file’s path, then remove the trailing backslash, then echo the command to preview it:

 @echo off

 FOR /F "tokens=* delims=" %%i in (filelist.txt) do (

     ECHO Copy attempt of this file: %%i

     FOR %%h IN ("%%i") DO (

          REM -- capture the file path
          SET filepath=%%~ph

          REM -- remove the trailing slash on the path
          SET filepath=%filepath:~0,1%

          REM -- echo the command to see how it looks  
          ECHO hobocopy "F:%%~ph" "V:\copy_test%%~ph" "%%~nxh"
     )
 )

Obviously that code doesn’t actually work, but I’m not sure how to proceed from here.

  • 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-27T12:54:03+00:00Added an answer on May 27, 2026 at 12:54 pm

    You were darn close to having a very good solution. You don’t need the %%h FOR loop. And your solution will fail if the path or file name contains ! (not likely, but it can happen)

    I’m not sure if you will run into any problem if the file is in the root directory. F: and F:\ usually have very different meanings. I did not address this potential problem in the solution below.

    @echo off
    FOR /F "delims=" %%i in (filelist.txt) do (
      ECHO Copy attempt of this file: %%i
      REM -- capture file path and file name
      SET "filepath=%%~pi"
      SET "filename=%%~nxi"
      REM -- enable delayed expansion so we can access variable assigned within loop
      SETLOCAL enableExtensions enableDelayedExpansion
      REM -- remove trailing backslash
      set "filepath=!filepath:~0,-1!"
      REM perform shadow copy on file
      hobocopy "F:!filepath!" "V:\copy_test!filepath!" "!filename!"
      REM -- disable delayed expansion so %%i expansion does not corrupt values containing !
      ENDLOCAL
    )
    

    I think Joop Egen’s comment is correct. I believe this one liner may work

    @echo off
    for /f "delims=" %%i in (filelist.txt) do hobocopy "%%~dp." "V:\copy_test%%~p." "%%~nx"
    

    This very simple solution should not have any problems with a root directory either.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have text file with a row like this: SendersTimeSeriesIdentification: COMPANY_A/COMPANY_B/REF_7/20090505 I'd like to
I have text file with some stuff that i would like to put into
I'm trying to append /index.html to some folder paths in a list like this:
I have a text file with paths to the list of files I want
I have list of folders path like /home/user/wwww /home/www/www/temp They are stored in a
I have a text file that contains a long list of entries (one on
I have a text file that contains a list of filenames, minus the extension,
I have a list of timestamps in a text file. I want to figure
If I have a list of data in a text file seperated by a
Okay, basically, I have a large list of phone numbers in a text file

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.