I'm studying today windows Under the system bat script , You want to traverse a directory and output the details of all the files in that directory . After a lot of search and exploration , This can be done with the following code :
@echo off set source_dir="C:\Users\leon\Desktop\test" for /R %source_dir% %%f
in(*.*) do ( echo Full path information : %%f echo Directory information : %%~dpf echo File prefix name : %%~nf echo
File suffix name :%%~xf echo Full file name : %%~nxf echo Path without suffix : %%~dpnf echo File modification time : %%~tf echo
File content size :%%~zf Byte ) pause
The results are as follows :
Full path information : C:\Users\leon\Desktop\test\test.txt
Directory information : C:\Users\leon\Desktop\test
File prefix name : test
File suffix name : .txt
Full file name : test.txt
Path without suffix : C:\Users\leon\Desktop\test\test
File modification time : 2020/07/09 14:58
File content size : 12 Byte
Please press any key to continue . .
If you just list a certain type of file ( such as *.doc), Then change it to the following statement :
@echo off set source_dir="C:\Users\leon\Desktop\test" for /R %source_dir% %%f
in(*.doc) do ( echo Full path information : %%f echo Directory information : %%~dpf echo File prefix name : %%~nf echo
File suffix name :%%~xf echo Full file name : %%~nxf echo Path without suffix : %%~dpnf echo File modification time : %%~tf echo
File content size :%%~zf Byte ) pause
Technology
Daily Recommendation