congdantoancau

Search files

Nov 22nd, 2021 (edited)
805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.10 KB | None | 0 0
  1. ::https://superuser.com/questions/1272715/how-to-search-and-find-all-the-files-with-particular-name-using-batch
  2. ::https://ss64.com/nt/ - An A-Z Index of the Windows CMD command line
  3. ::https://ss64.com/nt/commands.html - A categorized list of Windows CMD commands
  4. ::del - Delete one or more files.
  5. ::dir - Display a list of files and subfolders.
  6. ::endlocal - End localisation of environment changes in a batch file. Pass variables from one batch file to another.
  7. ::find - Search for a text string in a file & display all the lines where it is found.
  8. ::set - Display, set, or remove CMD environment variables. Changes made with SET will remain only for the duration of the current CMD session.
  9. ::setlocal - Set options to control the visibility of environment variables in a batch file.
  10.  
  11. @echo off
  12. setlocal
  13. rem change to the correct directory
  14. cd /d d:\
  15. rem count the files
  16. dir /b new.txt /s 2> nul | find "" /v /c > %temp%\count
  17. set /p _count=<%temp%\count
  18. rem cleanup
  19. del %temp%\count
  20. rem output the number of files
  21. echo Files found : %_count%
  22. rem list the files
  23. echo Files Paths :
  24. dir /b new.txt /s
  25. endlocal
Add Comment
Please, Sign In to add comment