2021年1月2日星期六

Move folders in their own first letter directory

I use this script to move folders in their own first letter directory

@echo off  setlocal enabledelayedexpansion    tree  for /d %%i in (*) do (    set first=%%i    set first=!first:~0,1!    md !first! 2>nul    if not "!first!" == "%%i" move "%%i" "!first!\%%i"   )  tree  

First letter directory are generated by this script. For example if I have folders name like these

Wachenfeldt - The  Пламень - Чужие  Von Stroheim - Lov  

first letter directory that are generated by this script could be

W  П  V  

I don't test this script if the first letter directory already exists before

Why is the problem? Script works partially because many folders are not moved in their own first letter directory and into CMD I read this error message:

file name or extension is too long

https://imgur.com/KujKMED.png

Example of folders name that are moved

Wachenfeldt - The Interpreter (2019) Progressive Death Metal  Whitby Bay - Gothic Attack Vehicle (2018) Black Metal  Пламень - Чужие (2017) Black Metal (D5)    W  |  |----  Wachenfeldt - The Interpreter....  |----- Whitby Bay - Gothic Attack....    П  |  |----- Пламень - Чужие (20...  

Example of folders name that are not moved (script doesn't works for them)

Withering Night - Within The Shadows We Lurk (2013) Black Metal (D5)  Woltemade - Siele Vir Die See (2019) Melodic Death Metal  Von Stroheim - Love_ Who Gets Love_ (2019) Doom_Post-Metal  
https://stackoverflow.com/questions/65546005/move-folders-in-their-own-first-letter-directory January 03, 2021 at 10:05AM

没有评论:

发表评论