代码改变世界

从指定路径下的N首歌曲随机复制到指定名字的M首歌曲

2016-04-24 21:37  双头蛇  阅读(202)  评论(0编辑  收藏  举报

@echo off
setlocal ENABLEDELAYEDEXPANSION
set path=%~dp0
set filename=!path!mp3.tmp
if "%1" equ "" (
echo ERROR_NO_PARAMETER
goto finished
)

set rand_switch=0
if "%2" equ "rand-on" (
set rand_switch=1
)

pushd %1 0>NUL 1>NUL 2>NUL
if ERRORLEVEL 1 (
echo can't find %1 folder
goto finished
)
dir /b /s *.mp3>!filename!
set cnt=10
:go
if !cnt! lss 100 (
if !rand_switch! equ 1 (
if exist !path!rearrange_file.exe (
!path!rearrange_file.exe !filename!
)
)
for /f "delims=" %%i in (!filename!) do (
copy %%i !path!\!cnt!.mp3
set /a cnt=!cnt!+1
if !cnt! geq 100 goto finished
)
goto go
)
:finished
if exist !filename! del !filename!
popd
pause