I have a text file RECORDS containing a list of addresses to series of record files from physionet website:
Person_01/rec_1
Person_01/rec_2
.
.
.
Person_90/rec_1
Person_90/rec_2
I need to execute a command as below to each line of text file as below:
wfdb2mat -r rec_1 -f 0 -t 20 > rec_1m.info
Here, wfdb2mat is the command known to windows to convert .dat data structure in windows to .mat structure known to MATLAB. Output report of this command execution is stored as .info in the same directory as RECORDS line.
I have written a batch file (convert.bat) as:
@echo off
for /f %%a in (RECORDS) do (wfdb2mat -r %%~a -f 0 -t 20 > %%~am.info)
to convert all files listed in RECORDS.
But unfortunately, there are two other files naming .mat and .hea which are store in the same directory as convert.batch and named rec_Xm.mat and rec_Xm.hea, where X is the record number listed in RECORDS.
Thus, I need to add an extra command in the for loop to move those files to their place in the folder named in RECORDS.
My batch file is so changed to:
@echo off
for /f %%a in (RECORDS) do (wfdb2mat -r %%~a -f 0 -t 20 > %%~am.info & move rec_*.* %%~a)
The problem is that %%~a contains folder name and file name together, like Person1/rec_1 and I just need the folder name to move those files to.
How can I split these strings in order that I can extract folder name in each loop iteration?
Based on my comment and my assumption of what your command is supposed to do
@Echo Off
For /F "Tokens=1-2 Delims=/" %%A In (RECORDS) Do (
wfdb2mat -r %%A/%%B -f 0 -t 20 >%%A/%%Bm.info
Move /Y %%B.* %%A)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With