批处理文件根据文件名移动

时间:2012-11-28 17:49:26

标签: sorting batch-file

我在.txt文件中收集了35k个歌词。它们都在一个文件夹中。 有没有办法在单独的文件夹中对它们进行排序(例如按艺术家名称)

这是截图,它看起来如何。

http://my.jetscreenshot.com/201/20121128-mrwo-76kb

提前致谢

1 个答案:

答案 0 :(得分:0)

如果没有错误,你不能这样做,你认为当你分割文件名时系统知道什么是艺术家或者标题名称?

例如 A-HA - 我的歌有3个 - 然后“ A ”成为艺术家且 HA- My歌曲成为歌曲名称。

因此不可能100%准确,您需要进行手动维修。

PS:对不起我的英文。

试试这个:

@Echo OFF

:: By Elektro H@cker


FOR %%@ IN (*) DO (
    Set "Filename=%%@"
    Call :Split "%FILENAME%"
    CMD /C "If not "%%Last_artist%%" EQU "%%artist_name%%" (ECHO Processing: "%%artist_name%%")"
    Call MKDIR "%%artist_name%%" 2>NUL
    Call COPY /Y "%%artist_name%%*" "%%artist_name%%\" >NUL
    Call Set "Last_artist=%%artist_name%%"
)
Pause&exit


:SPLIT
SET "title_name=%FILENAME:*-=%"
CALL SET "artist_name=%%Filename:%title_name%=%%"
CALL SET "artist_name=%%artist_name:~0,-1%%"
IF "%artist_name:~-1%" EQU " " (CALL SET "artist_name=%%artist_name:~0,-1%%")
GOTO:EOF

示例输出:

Processing: "Flyleaf"
Processing: "Flyleaf Vs. The Legion Of Doom"
Processing: "Folk Implosion"
Processing: "Foo Fighters"
Processing: "For All Those Sleeping"
Processing: "Foster The People"
Processing: "Four Year Strong"
Processing: "Franco & Oscarcito"
Processing: "From First To Last"
Processing: "Fuel"
Processing: "Full Blown Rose"
Processing: "Funeral For A Friend"
Processing: "Further Seems Forever"
Processing: "Garbage"
Processing: "Gemini"
Processing: "Georgina"
Processing: "Get Scared"