@echo off
REM - Check to see if there are any non-school related files on the system (mp3, jpg, png, exe)
REM - And print them out #bigbrother1984
cd G:\Assign2\
FOR /F "tokens=*" %%G IN ('dir /s /b "G:\Assign2\*.mp3"') DO echo %%G >> Found_MusicFiles.txt
FOR /F "tokens=*" %%G IN ('dir /s /b "G:\Assign2\*.JPG"') DO echo %%G >> Found_ImageFiles.txt
FOR /F "tokens=*" %%G IN ('dir /s /b "G:\Assign2\*.PNG"') DO echo %%G >> Found_ImageFiles.txt
FOR /F "tokens=*" %%G IN ('dir /s /b "G:\Assign2\*.exe"') DO echo %%G >> Found_GamesFiles.txt
例如,这会在 Assign2 下找到 .mp3、jpg、png、exe 文件,并打印出它找到的结果。但它会像这样打印出来 G:\Assign2\blah\blah\blah\blah\blah\Game.exe
我希望它打印出类似 \blah\game.exe
有任何想法吗?我尝试使用 %~nI,但我不知道如何使用它并且是批处理新手。