cmd - Troubleshooting Folder Creation based on User Input in Batch File -


i trying create simple batch file based on comma delimited input create series of nested folders. in following code, gsd master folder live. there user enter differing blocks separated commas. a,b,c or z,g,i , on.

based on input batch file should create block specific folders , nest appropriately. code have functions when user enters 1 block (i.e. a), falls apart , access denied errors when try run inputs of more 1 block (i.e. a,b,c). appreciated coding knowledge next none.

i trying nest block folders within other folders , folders under gsd.

@echo off  rem user input set /p gsd= enter gsd of project:  set /p blocks= enter blocks prepping drive separated commas (i.e. a,b,c,etc.):  set itemcount=0  mkdir %gsd%  mkdir 01-workspace_setup mkdir 02-tiles mkdir 03-orthos mkdir 04-saved_workspaces mkdir 05-backup mkdir 06-raw mkdir 07-excluded  mkdir ecw mkdir fixpoints mkdir imageframes mkdir pcr mkdir projectinfo mkdir seamlines mkdir trackinggrid mkdir fixto_boundary  :nextitem if "%blocks%" == "" pause & goto :eof  set /a itemcount+=1 /f "tokens=1* delims=," %%a in ("%blocks%") (     mkdir block_%%a     move /y block_%%a .\02-tiles     mkdir block_%%a     move /y block_%%a .\03-orthos     mkdir block_%%a     move /y block_%%a .\06-raw     mkdir block_%%a     move /y block_%%a .\07-excluded      mkdir block_%%a     move /y block_%%a .\ecw     mkdir block_%%a     move /y block_%%a .\fixpoints     mkdir block_%%a     move /y block_%%a .\imageframes     mkdir block_%%a     move /y block_%%a .\pcr     mkdir block_%%a     move /y block_%%a .\projectinfo     mkdir block_%%a     move /y block_%%a .\seamlines     mkdir block_%%a     move /y block_%%a .\trackinggrid     mkdir block_%%a     move /y block_%%a .\fixto_boundary      set "blocks=%%b"      move /y ecw .\01-workspace_setup     move /y fixpoints .\01-workspace_setup     move /y imageframes .\01-workspace_setup     move /y pcr .\01-workspace_setup     move /y projectinfo .\01-workspace_setup     move /y seamlines .\01-workspace_setup     move /y trackinggrid .\01-workspace_setup     move /y fixto_boundary .\01-workspace_setup      move /y 01-workspace_setup .\%gsd%     move /y 02-tiles .\%gsd%     move /y 03-orthos .\%gsd%     move /y 04-saved_workspaces .\%gsd%     move /y 05-backup .\%gsd%     move /y 06-raw .\%gsd%     move /y 07-excluded .\%gsd% ) goto nextitem    echo folder creation complete. have pleasant day! pause 

based on comments have altered code be:

@echo off  rem user input set /p gsd= enter gsd of project:  set /p blocks= enter blocks prepping drive separated commas (i.e. a,b,c,etc.):   mkdir %gsd%  mkdir 01-workspace_setup mkdir 02-tiles mkdir 03-orthos mkdir 04-saved_workspaces mkdir 05-backup mkdir 06-raw mkdir 07-excluded  mkdir ecw mkdir fixpoints mkdir imageframes mkdir pcr mkdir projectinfo mkdir seamlines mkdir trackinggrid mkdir fixto_boundary  if %blocks% == "" pause & goto :eof  %%a in (%blocks%) (     mkdir block_%%a     move /y block_%%a .\02-tiles     mkdir block_%%a     move /y block_%%a .\03-orthos     mkdir block_%%a     move /y block_%%a .\06-raw     mkdir block_%%a     move /y block_%%a .\07-excluded      mkdir block_%%a     move /y block_%%a .\ecw     mkdir block_%%a     move /y block_%%a .\fixpoints     mkdir block_%%a     move /y block_%%a .\imageframes     mkdir block_%%a     move /y block_%%a .\pcr     mkdir block_%%a     move /y block_%%a .\projectinfo     mkdir block_%%a     move /y block_%%a .\seamlines     mkdir block_%%a     move /y block_%%a .\trackinggrid     mkdir block_%%a     move /y block_%%a .\fixto_boundary  )  move /y ecw .\01-workspace_setup move /y fixpoints .\01-workspace_setup move /y imageframes .\01-workspace_setup move /y pcr .\01-workspace_setup move /y projectinfo .\01-workspace_setup move /y seamlines .\01-workspace_setup move /y trackinggrid .\01-workspace_setup move /y fixto_boundary .\01-workspace_setup  move /y 01-workspace_setup .\%gsd% move /y 02-tiles .\%gsd% move /y 03-orthos .\%gsd% move /y 04-saved_workspaces .\%gsd% move /y 05-backup .\%gsd% move /y 06-raw .\%gsd% move /y 07-excluded .\%gsd%  echo folder creation complete. have pleasant day! pause 

when run 1 block, works appears. block_%%a folders nested should , structure looks fine. when run no variable or multiple variables (a,b,c), thing blows , doesn't function. create folders block_%%a folders , not nest anything. tried create build folders nested couldn't figure out proper syntax that.

maybe i'm wrong access interpreter cmd create files above script, read line, memorize position, close file/folder atribute read-only , need change interpreter attributes read-only archives


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -