Total Commander Forum Index Total Commander
Форум поддержки пользователей Total Commander
Сайты: Все о Total Commander | Totalcmd.net | Ghisler.com | RU.TCKB
 
 RulesRules   SearchSearch   FAQFAQ   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Как найти папки, не содержащие определённых файлов
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Total Commander Forum Index -> Автоматизация Total Commander printer-friendly view
View previous topic :: View next topic  
Author Message
Ciber SLasH



Joined: 20 Aug 2005
Posts: 209
Location: С.-Петербург

Post (Separately) Posted: Wed Jan 16, 2013 16:52    Post subject: Reply with quote

Попытка ответить самому себе на 2 вопрос:
Code:
@echo off
setlocal ENABLEEXTENSIONS
chcp 1251 > nul

set "mask=*.jpg *.jpeg *.jp2 *.jpc *.gif *.png *.psd *.tif *.pcx *.tga *.bmp *.htm *.html *.shtm *.shtml *.txt *.avi *.mpg *.mpeg *.m2v *.mpe *.asf *.mov *.rm *.doc* *.xls* *.ppt*"
set input="%~dp0test.txt"
set output="%~dp0--.lst"

if not [%input%]==[""] (
   if exist %input% (
      for /f "usebackq delims==" %%i in (%input%) do (
         pushd "%%i"
         for /d /r %%j in (*) do (
            title "%%j"
            rem pushd "%%j"
            >nul 2>&1 dir /b/a-d/s %mask% || >>%output% echo(%%j\
            rem popd
         )
         popd
      )
   ) else (
      echo Error: file [%input%] not found!
   )
) else (
   echo Usage: %~nx0 ^<File-list^>
)

Но не хочет работать, если файл test.txt содержит русские имена Sad
Back to top
View user's profile Send private message
MVV



Joined: 15 Oct 2009
Posts: 4815
Location: Ростов-Дон

Post (Separately) Posted: Wed Jan 16, 2013 17:23    Post subject: Reply with quote

Попробуй:
Code:
for /f "usebackq delims==" %%i in (`type %input%`)

И входной файл в юникоде с маркером.
_________________
TCFS2 + TCFS2Tools: Полноэкранный режим и многое другое (обсуждение)
WINCMD.RU: AskParam, CopyTree, NTLinks, Sudo, VirtualPanel…
Back to top
View user's profile Send private message
Ciber SLasH



Joined: 20 Aug 2005
Posts: 209
Location: С.-Петербург

Post (Separately) Posted: Wed Jan 16, 2013 18:00    Post subject: Reply with quote

Скрипт заработал (я ошибся в указании путей)
Code:
@echo off
setlocal ENABLEEXTENSIONS
chcp 1251 > nul

set input="%~dp0test.txt"
set output="%~dp0--.lst"
:: Archives
set "mask=*.zip *.rar *.7z *.tgz *.gz *.tar *.bz2"
:: IMG
set "mask=%mask% *.iso *.nrg"
:: Graph
set "mask=%mask% *.jpg *.jpeg *.jp2 *.jpc *.gif *.png *.psd *.tif *.pcx *.tga *.bmp"
:: HTML
set "mask=%mask% *.htm *.html *.shtm *.shtml *.mht*"
:: Audio
set "mask=%mask% *.mp3 *.flac *.ape *.wma"
:: Video
set "mask=%mask% *.avi *.mpg *.mpeg *.m2v *.mpe *.asf *.mov *.rm"
:: Docs
set "mask=%mask% *.txt *.doc* *.xls* *.ppt* *.pdf"

if not [%input%]==[""] (
   if exist %input% (
      copy nul %output% > nul
      for /f "usebackq delims==" %%i in (%input%) do (
         echo -----
         echo Scan: %%i
         echo -----
         pushd "%%i"
         dir /b /a-d /s %mask% > nul 2>&1 || echo(%%i>>%output%
         for /d /r %%j in (*) do (
            REM title %%j
            echo %%j
            dir /s /b /a-d %mask% > nul 2>&1 || echo(%%j\>>%output%
            rem >nul 2>&1 dir /s /b /a-d %mask% || >>%output% echo(%%j\
         )
         popd
      )
   ) else (
      echo Error: file [%input%] not found!
   )
) else (
   echo Usage: %~nx0 ^<File-list^>
)

test.txt
Code:

C:\RECYCLER\
C:\tmp\


Добавлено спустя 55 минут:

С первым вопросом разобрался:
>nul 2>&1 dir /b/a-d/s %mask% || >>"%output%" echo(%%$\
Выполнить поиск файлов по всем вложенным каталога, начиная с текущего, соответствующих маске (при этом перенаправление ошибок и вывода идёт на ус-во null, чтобы не было никакого вывода и установился флаг %ERRORLEVEL%). Если файлов таких нет, то выполняется вторая команда после || которая записывает в выходной файл путь.
По идее можно переписать так:
dir /b/a-d/s %mask% > nul 2>&1 || echo(%%$\>>"%output%"

Все вопросы решены, тему можно закрывать Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> Автоматизация Total Commander All times are GMT + 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group