directory - Create folders based on second column in text file and then move files into their folders accordingly -


i have thousands of files received cnc machine sorted. have index lists files , categories. column separated tab character. here example of content of index file:

111.maz      aaa fgh 222.maz      bbb iyu 333.eia      cccdfew 444.maz      aaawer bb bbba 555.eia      aaa 123 666.m6m      ddd234 777.pbd      aaa .......      ..... 

thus, need following:

  1. create folders based on second column (successful), using excel separate column, batch create folder using following command:

for /f %d in (list.txt) md %d

  1. transfer files folders accordingly (?)

i'm not sure how second task. can point me in right direction?


after hundred times of running , failing, finally, have sorted of them respective folders @stephan , @josefz. tweaked code little bit create ones file exists.

for /f "tokens=1,*" %%g in (index.txt) (     if exist %%g (         md "%%~h" 2^>nul         move "%%~g" "%%~h"     ) ) 

have nice day!

no need excel. can parse index batch:

for /f "tokens=1,2 delims=<tab>" %%a in (index.txt) (   rem create folder, ignore "folder exists" error:   echo md "%%b" 2>nul   rem move file:    echo move "%%a" "%%b" ) 

note: instead of <tab> insert tabulator texteditor (notepad?)

remove echos, if output good.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -