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"
The problem is how you are reading the text file. You are using
tokens=3which 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
%iwhich 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 thisWhich saves the need for exporting the files to a list and then reading them back.