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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:53:00+00:00 2026-06-17T15:53:00+00:00

I have a batch file that is searching for PST files,creating a .txt file

  • 0

I have a batch file that is searching for PST files,creating a .txt file with the location of the searched files, then creating a folder in the Documents dir.
What I want to do is to copy the PST files to the new dir in the Documents dir.
Problem is I cant get the PST’s to copy to the new dir??
Any idea what am I doing wrong ?

The .bat look like this;

dir C:\*.pst /s /b > %USERPROFILE%\Desktop\pstFileLocation.txt
md %USERPROFILE%\Documents\Refresh_PST
for /F "tokens=3" %%v in ('pstFileLocation.txt') do copy "%i" "%USERPROFILE%\Documents\Refresh_PST"
  • 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-17T15:53:01+00:00Added an answer on June 17, 2026 at 3:53 pm

    The problem is how you are reading the text file. You are using tokens=3 which means you are trying to read the 3rd item in each line (by default items are separated by a space) and there is most likely not a 3rd item if they are just file paths.

    You are also trying to copy the variable %i which doesn’t exist.

    You can fix the the token issue using tokens=* to read the whole line as one item, but it would be easier and quicker to just do this

    md "%USERPROFILE%\Documents\Refresh_PST"
    for /r C:\ %%a in (*.pst) do copy "%%a" "%USERPROFILE%\Documents\Refresh_PST"
    

    Which saves the need for exporting the files to a list and then reading them back.

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

Sidebar

Related Questions

I have a Windows batch file that processes all the files in a given
I have several batch files that I call from a parent batch file. I
I have a batch file that automates copying a bunch of files from one
I have a batch file that does the following: @IF EXIST C:\Program Files\MyAppFolder (
I have a batch file that I usually invoke like this: longjob.cmd >result.txt 2>&1
I have a batch file that runs ant and then copies one of the
I have a batch file that allows me to go to particular folder based
I have a batch file that will check for updates within a directory then
I need to have a batch file that copies files (8) in my local
I have a batch file that does a lot of stuff, then at 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.