title: batch script to create folder based on another folder name (music library
body: <p>I've been searching and trying to create a basic batch script that will create a folder for every album i have in a directory..
  I can show an exemple of my library
  <a href="https://i.stack.imgur.com/0v6Di.png" rel="nofollow noreferrer">audio folder exemple</a></p>
  
  <p>I would like 
  Artist1 - 1 /
  Artist1 - 2 /
  Artist1 - 3 /
  Artist1 - ... /
  Artist2 - 1 /
  Artist2 - ... /
  ...</p>
  
  <p>in an artist1, artist2, artist3... folder with the individual folder moved. It would be nice to have the copied artist name deleted too but it's not necessary.
  It would be nice if it wasnt differentiating the non caps caracter from the caps too.</p>
  
  <p>I have 3000 albums in a folder and it's a pain to edit manually. It would take me a lot of work to edit manually and maybe a batch file is more useful for future usage too.
  I've seen file to folder batch and some other but i'm not sure to get how to edit them for my purpose.. 
  <strong>bulkrenameutility</strong> looks nice but not sure it achieve what i need</p>
  
  <p>EDIT 1 - 
  I've seen something like this which looks nice. 
  But i would like to be able to select a folder and not a file named .psd or .jpg</p>
  
  <p>//////</p>
  
  <pre><code>@echo off
  setlocal enabledelayedexpansion
  for %%A in (*.psd *.jpg) do (
     echo file found  %%A
     for /f "delims=" %%B in ("%%A") do set fname=%%~nB
     for /f "delims=" %%C in ("%%A") do set fextn=%%~xC
     for /f "tokens=1* delims=_" %%D in ("!fname!") do set folname=%%D
     echo folder name !folname!
     if not exist "!folname!" (
        echo Folder !folname! does not exist, creating
        md "!folname!"
     ) else (
        echo Folder !folname! exists
     )
     echo Moving file %%A to folder !folname!
     move "%%A" "!folname!"
     )
  echo Finished
  pause
  </code></pre>
  
  <p>//////</p>
  
  <p>Basicly it's doing this </p>
  
  <p>//////</p>
  
  <pre><code>@echo off
  
  :: Needed because you are working with variables that are immediately called
  setlocal enabledelayedexpansion
  
  :: Start of the loop to get all files with a psd or jpg Extension
  for %%A in (*.psd *.jpg) do (
     echo file found  %%A
  
  :: Grabs only the file name
     for /f "delims=" %%B in ("%%A") do set fname=%%~nB
  
  :: Grabs only the extension
     for /f "delims=" %%C in ("%%A") do set fextn=%%~xC
  
  :: Using the File name it separates it into 2 part using "_" as a delimiter so 120_low becomes 120 and low
     for /f "tokens=1* delims=_" %%D in ("!fname!") do set folname=%%D
     echo folder name !folname!
  
  :: Checks for the existence of the folder, if the folder does not exist it creates the folder
     if not exist "!folname!" (
        echo Folder !folname! does not exist, creating
        md "!folname!"
     ) else (
        echo Folder !folname! exists
     )
  
  :: Moves the file to the folder
     echo Moving file %%A to folder !folname!
     move "%%A" "!folname!"
     )
  echo Finished
  </code></pre>
  
  <p>//////</p>
  
  <p><a href="https://www.computerhope.com/forum/index.php?topic=152980.0" rel="nofollow noreferrer">https://www.computerhope.com/forum/index.php?topic=152980.0</a></p>