Answer the question
In order to leave comments, you need to log in
Batch file for archiving files in a folder (each file in a separate archive and with a unique password)?
Hello! Faced with the task of archiving all files in a folder, encrypting each file with a separate password.
all files for archiving are placed manually in a folder, respectively, you can also set a name for them. Based on my knowledge, it seems to me that it is easier to create text files with passwords with names similar to the names of files in the folder for archiving, and through a loop
-> read the file name in the folder for archiving
-> write it to a variable
-> run a comparison on the contents of this variable with the names of the password files in the folder
-> read the contents of the txt file with the password and write it to a variable
-> start archiving the file with the password specified in this variable
If it's easy for some guru to sketch out the syntax, I will be grateful :) I myself got a little confused about the filters for variables :(
Answer the question
In order to leave comments, you need to log in
The password can be randomly generated: %RANDOM%
True, the random number generator in cmd is still the same, in my opinion it just takes the time in seconds from the start of the OS and passes it off as a random number. But for your purposes it will do.
Then the passwords can be added to a file along with the names of the encrypted files.
@echo off
setlocal enabledelayedexpansion
for %%a in (*.txt) do (
set "password=%RANDOM%"
set "filename=%%~a"
echo.password = !password! file = !filename!
7z.exe a -t7z -p!password! "%%~dpna.7z" "%%~a"
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question