Page 1 of 1

populate csv

Posted: 29 Jan 2017 17:41
by ccarminati
I am using the following script to populate a csv file.

What do I need to change so the script will add filename+extension?

Right now only writes the filename.



Code: Select all

for %%a in (*.csv) do call :addID "%%~Na" "%%a"

goto :EOF

:addId
@echo off
for /f "usebackq delims=" %%b in (%2) do (
  > #.csv echo %%b
  goto :next
)
for /r %F in (*.*) do @echo %~nxF > %filename%
:next
for /f "usebackq skip=1 delims=" %%b in (%2) do (

  >> #.csv echo objects/%filename%,%filename%,%DATE%%%b
)
move #.csv %2

Re: populate csv

Posted: 29 Jan 2017 20:09
by Squashman
I saw this over on stack over flow as well and I am not really understanding what you are trying to do. You never set the variable %filename% in your code and I have no idea why you are breaking out of the FOR command after you CALL your label.

Re: populate csv

Posted: 30 Jan 2017 07:16
by ccarminati
Thanks for your reply.

The batch executes the following command on line 11:
for /r %F in (*.pdf) do @echo %%~nxF > %filename%

If I run same command inside folder I get:

for /r %F in (*.*) do @echo %~nxF
AROLDOALMEIDA2014.pdf

But when the batch writes into the csv it only writes AROLDOALMEIDA2014

Makes sense?