本帖最后由 miqilaosu 于 2019-6-25 09:35 编辑
回复 8# netdzb - @echo off
- setlocal ENABLEDELAYEDEXPANSION
- set "n=0"&set "nn=0"
- for /f "delims=" %%i in ('dir /a-d /b "*.mp3"') do (
- call set "str[!n!]=%%~i"
- set /a n+=1
- )
- for /f "delims=" %%a in ('type "ip.txt"') do (
- call set "str1[!nn!]=%%~a"
- set /a nn+=1
- )
- for /l %%d in (0,1,!n!) do (
- echo.!str[%%d]! !str1[%%d]!
- )
- pause
复制代码 上边是DOS的方法,下边的shell的方法,DOS没有数组不太好执行- powershell -NoProfile -ExecutionPolicy Bypass ^
- $text = Get-Content -Path c:\ip.txt;^
- $n=0;^
- foreach($file in dir *.mp3)^
- {^
- Write-Host($File.Name,$text[$n]);^
- $n+=1;^
- }^
- exit
- pause
复制代码
|