I wanted to merge in every Folder 2 existing txt files into one and save it in the same Folder as .csv. The Name of new File have to be Date and Time.
for /r C:\Users\Juan\Desktop\Konturograph\ %%G in (*.txt) do (
xcopy "%%G" "G%% %date% %time:~0,2%-%time:~3,2%-%time:~6,2%".csv
echo %%G
)
pause
I am trying with this but that just create 2 .cvs. I have no idea from Batch and I think I am very far from my Target, could you help me please?
Thank you very much in advance.
Grüße Juan
There is no such token as G%%
. If you want to copy the file from a .txt
extension to .csv
use %%~nG
for name of file, excluding extension.
@echo off
for /r "C:\Users\Juan\Desktop\Konturograph\" %%G in (*.txt) do (
xcopy "%%G" "%%~nG %date% %time:~0,2%-%time:~3,2%-%time:~6,2%.csv"
echo "%%G"
)
pause
However, seeing that you want to merge files, that will not work. try something like:
@echo off
for /r "C:\Users\Juan\Desktop\Konturograph\" %%G in (*.txt) do (
type %%G >> OUTPUT.csv
echo "%%G"
)
pause
You will not be able to use time in the timestamp as time changes during each loop, it will change the filename.