Q:

Connecting through plink and redirecting to file, not getting all the needed output in file

I'm using a batch file in Windows to connect to a Linux computer through SSH with plink to see if two certain files are up to date (they have to have today's date).
The command I use in the Windows batch file to execute plink:
plink.exe -ssh root@%THEIP% -m checkfiles.txt > temp\fileDates.txt

The "checkfiles.txt" in the Windows computer contains:
ls -l /folder/*file.dat.v* /folder/*file2.dat.v* > awk '{print $7}'

I then proceed to read "fileDates.txt" to see if both files are present and their dates.
I could delete the > awk '{print $7}' part and do it by hand on the batch file.
The problem comes when a file is missing, I get for example:
ls: cannot access /folder/*file.dat.v*: No such file or directory

I get that massage on screen and not in "fileDates.txt", and I only get the date for the second file, with no error about the first file not being found.
I'd like to have the error "No such file..." in "fileDates.txt" so I've been trying different redirection methods to no avail.
If that isn't possible, how can I tell when one file, the other or both are missing?
Thank you in advance.

A:

I found the answer. Thanks @PlasmaPower for your help (I'd upvote your answer, but I don't have enough reputation).
What was needed was two lines of code:
ls -l /folder/*file.dat.v* /folder/*file2.dat.v* &> $HOME/checkfiles.txt
cat $HOME/checkfiles.txt  | awk '{print $7}'

The first one to do a temporary file with both stdout and stderr, then another line doing the awk command.
Thank you very much!

