List specific directory in Windows - Filter in the list

Asked

Viewed 1,265 times

3

I have the scenario with the following directories in alphabetical order:

Y:\imagens\A001\B001\imagem.jpg
Y:\imagens\A001\B002\imagem.jpg
Y:\imagens\A002\B001\imagem.jpg
Y:\imagens\A002\B002\imagem.jpg
Y:\imagens\A003\B001\imagem.jpg
Y:\imagens\A003\B002\imagem.jpg
Y:\imagens\A004\B001\imagem.jpg
Y:\imagens\A004\B002\imagem.jpg

I am using the following command to list all files recursively and throwing the output into a file:

dir "Y:\imagens" /a-d /b /s > arquivo_de_saida.txt

It turns out that my command stopped listing the files when it was almost over and I don’t want to start all over again as it is millions of files.

I want to list only the directories after "A002".

  • without searching if there really is a solution for this... rename A001 and A002 to xA001 and xA002, and wheel dir "Y:\imagens\A*" /a-d /b /s > arquivo_de_saida2.txt

  • Thanks @Rovannlinhalis ... But it’s still impossible for me because there are 5000 directories but there are 2000.

  • A002 including or only starting from A003...?

  • Wow, just now I saw that question was asked almost 4 years ago...

1 answer

0

To list all who are .jpg recursively and after the folder Y:\imagens\A002 you can try using the where within a loop for filtered by find avoiding the folder A002 to list, and picking up on findstr using regex in the desired folders:


:: via linha de comando ::
   cd /d "Y:\imagens" && where /r . "*.jpg" | findstr /vc:"\A002" | findstr /r \A[0-9] 

:: via arquivo bat/cmd ::
   @echo off & cd /d "Y:\imagens" && where /r . "*.jpg" | findstr /vc:"\A002" | findstr /r \A[0-9]

:: usando um loop for na linha de comando ::
   @cd /d "Y:\imagens" && for /f ^tokens^=* %i in ('where /r . "*.jpg" ^| findstr /vc:"\A002" ^| findstr /r \A[0-9]')do @echo/%i

:: usando um loop For no bat/cmd ::
   @echo cd /d "Y:\imagens" && for /f ^tokens^=* %%i in ('where /r . "*.jpg" ^| findstr /vc:"\A002" ^| findstr /r \A[0-9]')do echo/%%i


  • Save exit in a log file. "%temp%\saida_salva.log"

:: via linha de comando ::
   @cd /d Y:\imagens && where /r . "*.jpg" | findstr /vc:"\A002" | findstr /r \A[0-9] >"%temp%\saida_salva.log" <nul

:: via arquivo bat/cmd ::
   @echo off & cd /d "Y:\imagens" && where /r . "*.jpg" | findstr /vc:"\A002" | findstr /r \A[0-9] >"%temp%\saida_salva.log" <nul

:: usando um loop For no bat/cmd ::
   @echo off & cd /d "Y:\imagens" && for /f ^tokens^=* %%i in ('where /r . "*.jpg" ^| findstr /vc:"\A002" ^| findstr /r \A[0-9]')do echo/%%i >"%temp%\saida_salva.log" <nul

:: usando um loop for na linha de comando ::
   @cd /d "Y:\imagens" && for /f ^tokens^=* %i in ('where /r . "*.jpg" ^| findstr /vc:"\A002" ^| findstr /r \A[0-9]')do @echo/%~i >"%temp%\saida_salva.log" <nul 

  • I tested the version "via bat/cmd file ::" and in my case it just hid the A002 folder and not "all previous folders".... for example A001 appeared normal.

  • @Ricardobohner Jeez! Then have add one more ^| findstr /vc:"\A001"... I’ll edit at home.. Valew

  • More and if only to list from A027 or something like that have to do it for each folder?

  • @Ricardobohner Now that the chips are down! Q does not!?

  • @Ricardobohner That would be to list the folders/paths excluding the items that are already in the file using findstr /v items_no_file.txt

  • Boy, I never thought of that possibility. Just list the files that do not exist in the listing that was half-finished...more will be that this whole process will not take more time than creating a file from scratch even if it has millions of files?

  • @Ricardobohner only testing that will know whether it takes longer, smaller or the same time...

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.