Solved Batch Move Files into corresponding folders.

June 3, 2015 at 11:12:01
Specs: Windows 7

I have files named as:-
... etc

I also have folders named as:-

Anyway to create a batch script that would move into the matching folder 2__-__the-raj, into 5__-__the-raj into 20__-__pictures etc

I have thousands of .md numbered files and folders.. theirs probably about 50 files that dont have a matching folder so I would not want them moved they just get skipped...

Is this possible?

See More: Batch Move Files into corresponding folders.

Report •

June 4, 2015 at 06:52:20
✔ Best Answer
tested briefly

::====== script starts here ===============
:: HORB.bat 2015-06-04 10:59:54.77
@echo off & setLocal enableDELAYedeXpansioN

pushd d:\HOFB2015
call :sub1

for /f "tokens=* delims= " %%a in ('dir/b/on/a-d *.md') do (
move %%a !%%~Na!
goto :eof

:sub1 alias
for /f "tokens=1* delims=___-___" %%i in ('dir/b/on/ad') do (
set %%i=%%i__-__%%j
goto :eof
::====== script ends here =================


M2 Get custom script or take private lessons

Report •
Related Solutions

Ask Question