Functional Requirements:
For example, there are 100 picture files in the face directory. The file name doesn't have to be regular
As shown in the following figure
We want to implement the following list:
Http://files.jb51.net/file_images/article/201305/2013051914225117.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225118.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225119.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225120.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225121.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225122.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225123.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225124.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225125.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225126.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225127.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225128.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225129.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225130.jpg
Http://files.jb51.net/file_images/article/201305/2013051914225131.jpg
Here is the implementation step:
The first step: we want to get the JPG, GIF, PNG format files in the current directory and save them to a list.txt text file.
Copy Code code as follows:
Dir *.jpg *.gif *.png/b >list.txt
Dir/b is just getting the filename
Step two: Loop through the for command in the bat to get the content of each row list.txt, and through echo enter the URL we want to add, and finally save it to the Pic.txt file
Copy Code code as follows:
for/f%%i in (list.txt) do echo http://files.jb51.net/file_images/article/201305/%%i >>pic.txt
The above two steps are complete, we can speak bat to write together. Because of the time interval problem, it is best to add a pause.
The complete BAT code is as follows:
Copy Code code as follows:
@echo off
Del list.txt/f
Dir *.jpg *.gif *.png/b >list.txt
Pause
for/f%%i in (list.txt) do echo http://files.jb51.net/file_images/article/201305/%%i >>pic.txt
How to use: The above file, save as Getlist.bat copy into the picture directory can be. Double-click Execute, and then press any key to it, the list of URLs is in Pic.txt.
Other netizens send articles can be combined
Batch processing (. bat) gets all the files in the specified directory and builds the list
Copy Code code as follows:
@echo off
:: Determine if the input path is a folder, and if so, get all the file names under the folder (including the subfolders)
:: If you want the file name to take the path, you need to change the%%~nxi on the dir line.
:: Code by JM Cmd@xp 2006-7-20
If exist List.txt del list.txt/q
: input
Cls
Set input=:
set/p input= Please enter the path to be judged:
Set "Input=%input:" =% "
:: The above sentence is to determine whether there are quotes in the%input%, and then remove.
If "%input%" = ":" Goto input
If not exist "%input%" goto input
For%%i in ("%input%") do if/i "%%~di" ==%%i goto input
pushd%cd%
cd/d "%input%" >nul 2>nul | | Exit
Set cur_dir=%cd%
popd
for/f "delims="%%i in (' dir/b/a-d/S "%input%") do echo%%~nxi>>list.txt
If not exist List.txt goto No_file
Start List.txt
Exit
: No_file
Cls
There are no separate files under the Echo%cur_dir% folder
Pause
Cloud Habitat Community Original article, please indicate the source http://www.jb51.net/article/37038.htm