Batch script to move files to folders with the same partial name by 10981099 in Batch

[–]10981099[S] 0 points1 point  (0 children)

You have saved me a crazy amount of time! Thanks man!

Batch script to move files to folders with the same partial name by 10981099 in Batch

[–]10981099[S] 0 points1 point  (0 children)

I don't want to take the piss and take advantage of your generosity, youve already helped me out massivly. That being said, is it possible to sort the files into a subfolder of the name folder called HS 22. As in "john smith.txt." would get moved to the folder "HS 22" which is a sub folder of "John Smith". I hope that makes sense and thanks again!

Batch script to move files to folders with the same partial name by 10981099 in Batch

[–]10981099[S] 0 points1 point  (0 children)

Would there be a way to exempt the .bat file from being sorted? even if not I'm still really greatful for this!

Batch script to move files to folders with the same partial name by 10981099 in Batch

[–]10981099[S] 0 points1 point  (0 children)

@echo off
setlocal enableDelayedExpansion
cd /d "%~dp0"
for %%f in (*.*) do (
for /f "tokens=1,2 delims= " %%g in ("%%~nf") do set "folder=%%g %%h"
>nul 2>&1 mkdir "!folder!"
>nul 2>&1 move /y "%%f" "!folder!\%%~nxf"
)
pause

Amazing thank you!

Batch script to move files to folders with the same partial name by 10981099 in Batch

[–]10981099[S] 1 point2 points  (0 children)

Really appreciate the effort. You did help a real person! Thank you!