我需要通过cmd请求将Spotify当前歌曲的输出输出到txt文件中

时间:2019-01-14 19:47:08

标签: windows cmd command-line terminal tasklist

我需要将输出限制为一行(窗口标题:Au5-Halcyon)。然后,我需要将结果写入txt文件。你能帮我吗?

C:\Windows\system32>for /f "tokens=* skip=9 delims= " %g in ('tasklist /v 
/fo list /fi "imagename eq  Spotify*"') do @echo %g >>C:\Users\Nikita\Desktop\txt\song.txt
Window Header: Au5 - Halcyon
Image name:     Spotify.exe
PID:            5884
Name of the session:     Console
№ of session:       2
RAM:         21 152 KB
Status:      Running
User:   DESKTOP-DIFPSDL\Nikita
CPU Time:       0:00:00
Window Header: No Data
Image Name:     Spotify.exe
PID:            6232
Name of the session:     Console
№ of session:       2
RAM:         82 824 KB
Status:      Not Responding
User:   DESKTOP-DIFPSDL\Nikita
CPU Time:       0:00:22
Window Header: AngleHiddenWindow
Image name:     Spotify.exe
PID:            4084
Name of the session:     Console
№ of session:       2
RAM:         180 368 KB
Status:      Unknown
User:   DESKTOP-DIFPSDL\Nikita
CPU Time:       0:00:36
Window Header: No Data

1 个答案:

答案 0 :(得分:0)

在PowerShell中进行了

CHCP 65001 | tasklist /v /fo list /fi "imagename eq  Spotify*" |select -first 10 |select -last 1 | Foreach-Object {$_.Replace('Window Title:', '')}| Out-File -filepath C:\Users\Nikita\Desktop\txt\Song.txt