I want to loop through a CSV file and create a full path variable out of two columns - and only if one specific column has the value "Folder".
This actually works right now, but the not working part is the creation of the path variable.
two points:
the two columns I look at are the deepest folder and the root folders aboth. Like this: first/first1/ + second = first/first1/second
So, the deepest folder will always be filled and I can just take it like it comes.
The folders above will either be filled or it will be a 0 standing in the column. Also the string will have a "/" which I have to CUT and replace with a backslash ..
Here's my code:
For /F "tokens=1-7 delims=;" %%a in (L:/Mappe1.csv) Do (
if "%%b"=="Folder" (
set folder=%%c
if NOT %%f==0 (
set rootFolder ==f
rem check for slash..
if %rootFolder=~-1%==/ (
rem cut it out
SET rootFolder=%rootFolder:~0,-1%
)
rem both variables set
set finalPath=%rootFolder%%folder%
) else (
rem just the folder
set finalpath=%folder%
)
echo %finalpath%
)
)
Sampe of the CSV:
ID;PROGID;NAME; PARENTID; PARENT_FOLDER;PATH; ISNTANCE; DESC; ORDER; 23;Folder;Stammordner;4;4;PRODUKTION/;0;;;
What's not working:
right now I get the "Echo is off" output everytime I run. I think that somehow the finalpath is not set, but I don't get where.
also I don't know if the way I do it is the common way - I'm so much new to batch - even if I'm a developer its somehow very complicated for me ..
Regards
csvfile anddescribe the taskthen we may find a more straight forward way to do it.set rootFolder ==fis a syntax error. You also need to use delayed expansion to change a variable within a loop, and use !variable! syntax.