Hi All,
I have a folder with multiple txt files in csv format with name convention Something_something_something_XXXXXXXX.
txt where XXXXXXXX is date.
Now I need to join those files in one and each row needs to have a the date XXXXXXXX from respective file added as column.
So far I was able to find way to add whole file name to the row. I have found how trim file name to keep only XXXXXXXX.txt
But I am not able either to remove the .txt nor to add the trimed name to rows. Below is the code for adding name file:
for %%A in (*.txt) do (
echo Processing file '%%A'
FOR /F "delims=" %%L in (%%A) do (
ECHO %%L , %%A >> New.txt
)
)
I have found this to trim the file name so it leaves last 11 chararacters so XXXXXXXX.txt
SET VAR=%%A
CALL ECHO/%%VAR:~-11%%&ECHO/
don't know how to use it in ECHO %%L , %%A >> New.txt
I have seen the %~nA supposedly should return only file name so I could get rid of txt but could not find syntax that would work.
This is probably easy but I am sooo... confused with examples I have seen that I can figure out how to join the dots.