Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

The dir command is defective


May 22, 2021 DOS Command learning manual



One


—— pengfei


@echo off

for /f "tokens" %%i in ('dir /s /a-d /b'D:-Share iles?information?f*")" do (

echo %%i

echo %%i>>file.txt

)

pause


Extract all existing f files under this folder.

Information.


The extracted file is generated into .txt file


The folder's wrong!


The ftp is normally extracted .txt


ok The problem has arisen


Extracted to Ping 014.jpg are not saved with f characters, but there are spaces in the middle of the file.


D: smh.com." file photo / Playboy - 11961873 - 218529.jpg


This file has a symbol.


D: share iles, profile, ADSL, ftp2.txt

D: smh.com..jpg u.com."

D: smh..jpg com.u.u.com."

D: smh.com.u.com." smh.com.u.com.jpg."

D: smh..jpg com.u.com."

D: smh.com.u.jpg.u.com."

D: smh.com.u.com." smh.com.u.com.jpg."

D: smh.com.u.u.com/share-iles/photos/1/019.jpg

D: smh.com.u.jpg.com."

D: smh.com.u.jpg.com."

D: smh..jpg com.u.com."

D: smh.com.u.jpg.com." smh.com.u.com."

D: smh.com.u.jpg.u.com."

D: smh..jpg com.u.u.com."

D: smh.com.u.jpg.com."

D: smh.com.u.u.jpg.com."

D: smh.com..jpg u.com." smh.com.u.com."

D: smh.com.u.jpg.com."

D: smh.com.u.u.jpg.com."

D: smh.com..jpg u.com."

D: smh.com..jpg u.com."

D: smh.com.u.com." smh.com.u.com.jpg."

D: smh.com..jpg u.com."

D: smh.com.u.jpg.com."

D: smh..jpg com.u.u.com."

D: smh.com.u.jpg.com."

D: smh..jpg com.u.com."

D: smh.com.u.com." smh.com.u.com.jpg."

D: smh..jpg com.u.com."

D: smh.com.u cmy8543_61.gif.com."

D: smh.com.u.com.misukhot_44.gif"

D: smh.com.u.com.misukhot_80.gif"

D: smh.com.u refiju_42.jpg.com."

D: smh.com.u.com.refiju_43.jpg"

D: smh.com.u.gif.com."

D: smh.com.u.jpg.com."

D: smh.com..jpg u.com."

D: smh.com.u.jpg.com."

D: smh.com..com./photo/photo/photo-032.jpg

D: smh.com..jpg u.com."

D: smh.com.u.jpg.com."

D: smh.com.u.u.com..com/share-iles/photo-photo-006.jpg

D: smh.com.u.jpg.com."

D: smh.com.u..jpg u.com., smh.com..com." Photo smh.com."

D: smh.com.u.com." Photo/Playboy/11961851_218527.jpg

D: smh.com." file photo / Playboy - 11961873 - 218529.jpg


Two


—— namejm


Compare the following two pieces of code:

1、

@echo off

for /f "tokens=*" %%i in ('dir /a /b /s "D:\test"') do (

echo %%~ai

)

pause


2、

@echo off

for /f %%i in ('dir /a /b "D:\test.txt"') do (

echo %%~ai

)

pause


1's code correctly picks up the properties of each file, but 2's code picks up the properties of the test .txt directory.

The solution would be to replace 'dir /a /b' in 2 with 'D:'test.txt' with 'd:'test.txt'