Solved Batch Move Files into corresponding folders.

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

I have files named as:-

2.md
5.md
20.md
100.md
1253.md
... etc

I also have folders named as:-
2__-__the-raj
5__-__the-raj
20__-__pictures
100__-__the-mail
1253__-__images

Anyway to create a batch script that would move 2.md into the matching folder 2__-__the-raj, 5.md into 5__-__the-raj 20.md 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 •

#1
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

:main
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