populate csv

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ccarminati
Posts: 2
Joined: 29 Jan 2017 17:36

populate csv

#1 Post by ccarminati » 29 Jan 2017 17:41

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
Last edited by aGerman on 29 Jan 2017 17:52, edited 1 time in total.
Reason: Please use code formatting

Squashman
Expert
Posts: 3737
Joined: 23 Dec 2011 13:59

Re: populate csv

#2 Post by Squashman » 29 Jan 2017 20:09

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.

ccarminati
Posts: 2
Joined: 29 Jan 2017 17:36

Re: populate csv

#3 Post by ccarminati » 30 Jan 2017 07:16

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?

Post Reply