A
A
anatoly_tim2015-03-05 16:41:01
cmd/bat
anatoly_tim, 2015-03-05 16:41:01

A script for searching and archiving files according to a template, how to implement it on cmd?

Good afternoon.
It is required to make a script that will search for files with the required extension and then archive them.
The search is performed by the command:
WHERE /R C:\ *.*
At the output we get a list of files and we need to pass them to the input of the archiving command, everything is clear with one file, but what to do when we have several files and how to enter their names in the name of the variable passed to the archiver.
Thank you very much in advance. I would be grateful for any advice on how to implement this using windows cmd

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
ldv, 2015-03-05
@anatoly_tim

sevenzip.sourceforge.jp/chm/cmdline/switches/recur...
If you need to create an archive for each file, then create the following cmd file:

chcp 1251
for /F "tokens=*" %%i in ('where /R "C:\" *.*') do "C:\Program Files\7-Zip\7z.exe" a "%%i.7z" "%%i"

7-Zip archiver

3
386DX, 2015-03-05
@386DX

WHERE /RC:\ *.*doc >c:\list.lst
or
dir /s /b *.doc >c:\list.lst then
feed the list to the archiver
However, such scripts were written 15 years ago, it’s easier to find ready-made

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question