echo offsetlocal enabledelayedexpansionset source_folder=Z乡村振兴表7月份工作set output_file=Z乡村振兴表7月份工作txtfor r source_folder F in do echo Foutput_fileecho File paths extracted successfully!endlocal
The given batch script is used to extract file paths from a specified folder and its subfolders, and save them to a text file.
Here is an explanation of the script:
-
@echo off: This command is used to turn off the echoing of commands in the batch script. -
setlocal enabledelayedexpansion: This command enables the use of delayed variable expansion. -
set "source_folder=Z:\乡村振兴表\7月份工作": This command sets thesource_foldervariable to the path of the folder from which file paths need to be extracted. -
set "output_file=Z:\乡村振兴表\7月份工作.txt": This command sets theoutput_filevariable to the path where the extracted file paths will be saved. -
for /r "%source_folder%" %%F in (*) do (: This command starts a loop that iterates through all files (denoted by*) in thesource_folderand its subfolders. -
echo %%F>>"%output_file%": This command appends the file path (%%F) to theoutput_fileusing the>>operator. -
): This command marks the end of the loop. -
echo File paths extracted successfully!: This command displays a success message after the loop completes. -
endlocal: This command ends the local scope and restores the previous environment variables.
Overall, this script will extract the file paths from the specified folder and save them to a text file specified by output_file
原文地址: https://www.cveoy.top/t/topic/iuN7 著作权归作者所有。请勿转载和采集!