Solved Move folders based on first letter of folder name

June 17, 2015 at 01:50:31
Specs: Windows 7
I was wondering how you would move all folders (w/ contents) in a directory with two or more characters in it's name, into a newly created folder (A-Z) that begins with the first letter of it's name.

Example of folders:

Larry Bird
Larry Legend

Will all be moved to a newly created folder (by the batch):

L

I've been able to find batch solutions for moving files to folders based on the first letter, haven't been able to find solutions that can move "folders" based on the first character.

Thanks.


See More: Move folders based on first letter of folder name

Report •

#1
June 17, 2015 at 19:24:46
✔ Best Answer
@echo off & setllocal enabledelayedexpansion
for /f "tokens=*" %%a in ('dir /ad') do (
set alpha=%%a
set alpha=!alpha:~0!
md !alpha! 2>nul
move %%a !alpha!
)
::======== end batch
not tested, be sure to do a "dry run" before things get hashed.

Report •
Related Solutions


Ask Question