Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: batch file to move files into new folder based on artists name only before -  (Read 5582 times)

0 Members and 1 Guest are viewing this topic.

DUBious

    Topic Starter


    Newbie

    • Experience: Familiar
    • OS: Windows 10
    Hi all, I tried to modify this code for my situation, and think it's ok, but i'd also like to add something else. I have about 60k of mp3 and .cdg karaoke files in one folder with multiple artists, I am looking to run a batch file to move all files by a particular artist into a new folder with the artists name and add "greatest hits" to each new folder that gets created. All files have a - after artists name, so I assume this is the delimeter. (coding novice) - would really appreciate and advice or help is getting the code right for the batch file please.....thanks in advance.

    Hope this makes sense... and one last thing, do i just remove the text echo to get rid of the pauses ?

    @echo off
    setlocal enabledelayedexpansion
    for %%A in (*.mp3 *.cdg) 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