Can anyone help on extending a command.
Moderator: DosItHelp
Re: Can anyone help on extending a command.
Sorry but most of it now...
All this is well over the top of my head.
All this is well over the top of my head.
Re: Can anyone help on extending a command.
Can I just get it straight in my head.
I have this command
@echo off
for /d %%a in ("C:\Downloads\*") do (
if not exist "C:\COMPLETED\%%~na.zip" (
7za.exe a "C:\COMPLETED\%%~na.zip" -t"zip" -m"em=ZipCrypto" "Far" -p
) else (
echo(Error cannot zip directory; target zip file name is occupied
)
)
Am I right in saying that this will zip the folder ? It mentions 7ZA.exe and looking for it. Ive looked in C\PROGRAM FILES\7ZIP and cant see 7xa.exe folder anywhere. Am I missing it? Ive downloaded the program from the internet.
I have this command
@echo off
for /d %%a in ("C:\Downloads\*") do (
if not exist "C:\COMPLETED\%%~na.zip" (
7za.exe a "C:\COMPLETED\%%~na.zip" -t"zip" -m"em=ZipCrypto" "Far" -p
) else (
echo(Error cannot zip directory; target zip file name is occupied
)
)
Am I right in saying that this will zip the folder ? It mentions 7ZA.exe and looking for it. Ive looked in C\PROGRAM FILES\7ZIP and cant see 7xa.exe folder anywhere. Am I missing it? Ive downloaded the program from the internet.
Last edited by Squashman on 18 Apr 2018 14:25, edited 1 time in total.
Reason: MOD EDIT: Use code tags please.
Reason: MOD EDIT: Use code tags please.
Re: Can anyone help on extending a command.
Your very first post in this thread said you were using 7zA.exe.
Re: Can anyone help on extending a command.
My apologies and this prob where confused. Looked in 7zip folder in c\program files and defentally not got 7ZA in there . What do I do to get it
The old command I just copied off the net
The old command I just copied off the net
Re: Can anyone help on extending a command.
Does your 7zip folder in "c:\program files" contain a file named "7z.exe"?
If the answer is "Yes.", then just use "7z.exe".
If the answer is "No.", then just download any version from here:
http://www.7-zip.de/download.html.
If the VBS does what you need, then just execute the above 7z command with the right parameters in a dosshell; my suggestion:
Code: Select all
Option Explicit
Const strDLFolder = "C:\Downloads"
Dim objFSO, objWShell, objDLFolder, strNewFolder, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWShell = CreateObject("WScript.Shell")
If Not objFSO.FolderExists(strDLFolder) Then objFSO.CreateFolder(strDLFolder)
objWShell.CurrentDirectory = strDLFolder
Set objDLFolder = objFSO.GetFolder(strDLFolder)
If objDLFolder.Files.Count = 0 Then WScript.Quit
Do
Err.Clear
strNewFolder = InputBox("Folder Name", vbLf & "Enter the name of the folder to be created:")
If strNewFolder = False Then WScript.Quit
On Error Resume Next
objFSO.CreateFolder strNewFolder
Loop While Err.Number <> 0 Or Not objFSO.FolderExists(strNewFolder)
On Error Goto 0
For Each objFile In objDLFolder.Files
objFSO.MoveFile objFile.Name, strNewFolder & "\"
Next
objWShell.Run """%comspec%"" /K """"C:\program files\7zip\7za.exe"" a ""C:\COMPLETED\" & strNewFolder & ".zip"" -t""zip"" -m""em=ZipCrypto"" """ & strNewFolder & """ -p""", 1, True
I used "%comspec%"" /K..." to call the thell because then you may see potential errors popping up.
If the above line does what you want, then replace that "/K" with a "/C", so the dos window will close automatically.
penpen
Re: Can anyone help on extending a command.
Just to check..
I save that script as a .VBS script? If so i get this error come up
line 6
char 1
error 2 loop without do "
Code 800a04E
I save that script as a .VBS script? If so i get this error come up
line 6
char 1
error 2 loop without do "
Code 800a04E
Re: Can anyone help on extending a command.
I haven't tested that script before, because you posted it above and said that script "does what it needs to but what I need to do is after the folder has been merged I need to 7zip the folder and password protect".
But after testing it, i found no error it seems to work without any errors (at least under my windows 10, where i just double clicked the file "test.vbs").
How do you execute it to get the error?
Edit: Do you use notepad.exe to create the file, and do you save the text file in ANSI coding?
penpen
But after testing it, i found no error it seems to work without any errors (at least under my windows 10, where i just double clicked the file "test.vbs").
How do you execute it to get the error?
Edit: Do you use notepad.exe to create the file, and do you save the text file in ANSI coding?
penpen
Re: Can anyone help on extending a command.
pen pen
Donno what im doing wrong but done everything you said and it just not having it. I had found this .cmd script on internet and tried it out and it works and does 70% of what I need to do.
It launches DOS as expected and asks for a password. Trouble im having is its asking for password on every file.
1) Can that be changed so input it once and it copies over same password for all files.?
2) Can you make the password visable when typing in as some people would input correct password and then forget it.
3) Its saving correctly as 7zip files but not creating a new folder and moving them into it am I able to do that after zipping individual files and password protecting.
Am I right in saying when it asks for password before 7 zipping it saves that password to the folder?
Script below
Donno what im doing wrong but done everything you said and it just not having it. I had found this .cmd script on internet and tried it out and it works and does 70% of what I need to do.
It launches DOS as expected and asks for a password. Trouble im having is its asking for password on every file.
1) Can that be changed so input it once and it copies over same password for all files.?
2) Can you make the password visable when typing in as some people would input correct password and then forget it.
3) Its saving correctly as 7zip files but not creating a new folder and moving them into it am I able to do that after zipping individual files and password protecting.
Am I right in saying when it asks for password before 7 zipping it saves that password to the folder?
Script below
Code: Select all
@echo off
cls
SETLOCAL EnableDelayedExpansion
set DL=C:\Downloads
for /f "tokens=1,2 delims=." %%a in ('dir /b /a-d "!DL!"') do (
set fn=%%a
set fe=%%b
cd !dl!
"C:\Program Files\7-Zip\7z.exe" a -tzip "!fn!.7z" -p "!fn!.!fe!" '-x!*.7z' -sdel
)
move *.7z zipped
Last edited by Squashman on 18 Apr 2018 14:21, edited 1 time in total.
Reason: MOD EDIT: USE CODE TAGS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Reason: MOD EDIT: USE CODE TAGS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Re: Can anyone help on extending a command.
I am thoroughly confused on what your intended goal is. Reading back at all your questions you originally had a script that was moving files to a a new folder, then zipping that folder to an output destination. Now you want to zip each file and password protect each file?tweacle wrote: ↑18 Apr 2018 14:17pen pen
Donno what im doing wrong but done everything you said and it just not having it. I had found this .cmd script on internet and tried it out and it works and does 70% of what I need to do.
It launches DOS as expected and asks for a password. Trouble im having is its asking for password on every file.
1) Can that be changed so input it once and it copies over same password for all files.?
2) Can you make the password visable when typing in as some people would input correct password and then forget it.
3) Its saving correctly as 7zip files but not creating a new folder and moving them into it am I able to do that after zipping individual files and password protecting.
Am I right in saying when it asks for password before 7 zipping it saves that password to the folder?
Script below
Code: Select all
@echo off cls SETLOCAL EnableDelayedExpansion set DL=C:\Downloads for /f "tokens=1,2 delims=." %%a in ('dir /b /a-d "!DL!"') do ( set fn=%%a set fe=%%b cd !dl! "C:\Program Files\7-Zip\7z.exe" a -tzip "!fn!.7z" -p "!fn!.!fe!" '-x!*.7z' -sdel ) move *.7z zipped
Also, look at the previous code on how to get the base file name and file extension. You even used it in one of your code posts. This is not the proper way to split the file name from the file extension because file names are allowed to have periods as well. My.file.name.ext
Re: Can anyone help on extending a command.
To be honest:
I think you are trying to execute a wrong vbs file, because the error message "line 6, char 1 , error 2 loop without do, Code 800a04E" doesn't make any sense:
There is no loop in line 6, in the above vbs-file.
I think i will stick with your vbs script file, and translate that to batch, because it does what you wanted to.
So that should be a batch file doing what you need:
Code: Select all
@echo off
setlocal enableExtensions enableDelayedExpansion
set "strDLFolder=C:\Downloads"
if not exist "%strDLFolder%" md "%strDLFolder%"
pushd "%strDLFolder%"
2>nul (>nul dir /b /A:-D *) || exit /b
:do
set "strNewFolder="
set /p "strNewFolder=Enter the name of the folder to be created: "
if not ^"!strNewFolder:"=!" == "!strNewFolder!" goto :do
md "%strNewFolder%" || goto :do
move "*" "%strNewFolder%"
"C:\Program Files\7zip\7z.exe" a "C:\COMPLETED\%strNewFolder%.zip" -t"zip" -m"em=ZipCrypto" "%strNewFolder%" -p
popd
goto :eof
You could use set/P to get the password, but i wouldn't recommend it.
You may want to type the password to notepad, and copy paste it to the cmd shell window.
I'm unsure, but i think tweacle doesn't want that behaviour (or @tweacle am i misunderstanding your first point?)
penpen
Re: Can anyone help on extending a command.
ladies and gents
I think im confusing everyone here and my apologies on that . Just so I can bring it to a close can someone confirm which will be the easiest
Thinking about what im trying to do and if its easier but aint got no script and not a clue where to start:-
1) create a new folder in C:\downloads and get it to ask me what the name going to be
2) move files in c:\downloads that are not zipped into the new named folder.
3) 7 ZIP and password protect the folder with it asking me what the password going to be. .
The other method that I have been advised is below and has a command that is a script I believe.What I think it does in script is below...
1) 7zip all the files that are not already zipped and in folders situated in C\DOWNLOADS.
2) When the command starts running in ms dos it asks me for a password. I need that password to be input once and then uses the same one for all the files that need zipping.
3) Once zipped it need it to ask me what the folder name is going to be so it creates a new folder in C\DOWNLOADS
4) When new folder has been created I need all the files that ive zipped moved into it. If possible I also need the folder password protected with the same password that was put in when using ms dos.
I know its a bit of a risk but am I able to see the password then typing it at the start in ms dos. All the files once zipped and passworded they will be on a secure server that only 2 people have access to but there are numerous people creating the folders and if they make a mistake it gonna be hard.
Can I also confirm that when I create password on ms dos and zipping it will always remain
@echo off
cls
SETLOCAL EnableDelayedExpansion
set DL=C:\DOWNLOADS
for /f "tokens=1,2 delims=." %%a in ('dir /b /a-d "!DL!"') do (
set fn=%%a
set fe=%%b
cd !dl!
"C:\Program Files\7-Zip\7z.exe" a -tzip "!fn!. set /p PW=”Please type password:” set /p FL=”Please type folder name:”
move *.7z !FL!
THanks
I think im confusing everyone here and my apologies on that . Just so I can bring it to a close can someone confirm which will be the easiest
Thinking about what im trying to do and if its easier but aint got no script and not a clue where to start:-
1) create a new folder in C:\downloads and get it to ask me what the name going to be
2) move files in c:\downloads that are not zipped into the new named folder.
3) 7 ZIP and password protect the folder with it asking me what the password going to be. .
The other method that I have been advised is below and has a command that is a script I believe.What I think it does in script is below...
1) 7zip all the files that are not already zipped and in folders situated in C\DOWNLOADS.
2) When the command starts running in ms dos it asks me for a password. I need that password to be input once and then uses the same one for all the files that need zipping.
3) Once zipped it need it to ask me what the folder name is going to be so it creates a new folder in C\DOWNLOADS
4) When new folder has been created I need all the files that ive zipped moved into it. If possible I also need the folder password protected with the same password that was put in when using ms dos.
I know its a bit of a risk but am I able to see the password then typing it at the start in ms dos. All the files once zipped and passworded they will be on a secure server that only 2 people have access to but there are numerous people creating the folders and if they make a mistake it gonna be hard.
Can I also confirm that when I create password on ms dos and zipping it will always remain
@echo off
cls
SETLOCAL EnableDelayedExpansion
set DL=C:\DOWNLOADS
for /f "tokens=1,2 delims=." %%a in ('dir /b /a-d "!DL!"') do (
set fn=%%a
set fe=%%b
cd !dl!
"C:\Program Files\7-Zip\7z.exe" a -tzip "!fn!. set /p PW=”Please type password:” set /p FL=”Please type folder name:”
move *.7z !FL!
THanks
Re: Can anyone help on extending a command.
I am tapping out!
Re: Can anyone help on extending a command.
This one is be the easiest:
The other approach has some serious issues - for example that sync issue:tweacle wrote: ↑19 Apr 2018 03:41Thinking about what im trying to do and if its easier but aint got no script and not a clue where to start:-
1) create a new folder in C:\downloads and get it to ask me what the name going to be
2) move files in c:\downloads that are not zipped into the new named folder.
3) 7 ZIP and password protect the folder with it asking me what the password going to be.
If you add a file to "C:\downloads", after your script has zipped all files in it, but before you moved all files to the subfolder, then that file is moved, but not packed into any zip.
It doesn't matter where the files location is at the end. If you want "evryone" to create the files, then you litterally want to give those people the password.tweacle wrote: ↑19 Apr 2018 03:41I know its a bit of a risk but am I able to see the password then typing it at the start in ms dos. All the files once zipped and passworded they will be on a secure server that only 2 people have access to but there are numerous people creating the folders and if they make a mistake it gonna be hard.
If you really plan to do it that way, it is faster to not use any password, while the security level is exactly the same (== completely unsecure).
This depends on what you mean?!
A file's password could change if the file gets corrupted:
But then your main problem is, that the data most probably is also corrupted, and therefore lost.
The zip format doesn't support passwords per zip, it only supports passwords per file:
So every file within the zip file could have its own password.
If you mean something different you may want to clarify.
penpen
Re: Can anyone help on extending a command.
Following what you have put penpen it sounds very difficult and full of security risks so I think I will forget the offer of password.
What I can do is 7 zip the files into a folder and then send on a secure server to individual people with a password to access the folder off the server.
I have the script below which creates a folder for me of which it 7 zips the individual files. Can I change that so that it 7 zips the new created folder instead of the individual files?
If possible could you just amend what ive posted and post it all back on here.
BIG BIG thanks in advance
@echo off
setlocal enableExtensions enableDelayedExpansion
set "strDLFolder=C:\Downloads"
if not exist "%strDLFolder%" md "%strDLFolder%"
pushd "%strDLFolder%"
2>nul (>nul dir /b /A:-D *) || exit /b
:do
set "strNewFolder="
set /p "strNewFolder=Enter the name of the folder to be created: "
if not ^"!strNewFolder:"=!" == "!strNewFolder!" goto :do
md "%strNewFolder%" || goto :do
move "*" "%strNewFolder%"
"C:\Program Files\7zip\7z.exe" a "C:\COMPLETED\%strNewFolder%.zip" -P"zip" -m"em=ZipCrypto" "%strNewFolder%" -p
popd
goto :eof
What I can do is 7 zip the files into a folder and then send on a secure server to individual people with a password to access the folder off the server.
I have the script below which creates a folder for me of which it 7 zips the individual files. Can I change that so that it 7 zips the new created folder instead of the individual files?
If possible could you just amend what ive posted and post it all back on here.
BIG BIG thanks in advance
@echo off
setlocal enableExtensions enableDelayedExpansion
set "strDLFolder=C:\Downloads"
if not exist "%strDLFolder%" md "%strDLFolder%"
pushd "%strDLFolder%"
2>nul (>nul dir /b /A:-D *) || exit /b
:do
set "strNewFolder="
set /p "strNewFolder=Enter the name of the folder to be created: "
if not ^"!strNewFolder:"=!" == "!strNewFolder!" goto :do
md "%strNewFolder%" || goto :do
move "*" "%strNewFolder%"
"C:\Program Files\7zip\7z.exe" a "C:\COMPLETED\%strNewFolder%.zip" -P"zip" -m"em=ZipCrypto" "%strNewFolder%" -p
popd
goto :eof
Re: Can anyone help on extending a command.
Sorry, i had few time.
There is no difference between those two things:
You zip a folder by zipping all files within that folder.
Beside this you have a typo in the copy of my code, that you have posted:
The "-P" in the "7z.exe"-line must be a "-t".
penpen
What do you mean?
There is no difference between those two things:
You zip a folder by zipping all files within that folder.
Beside this you have a typo in the copy of my code, that you have posted:
The "-P" in the "7z.exe"-line must be a "-t".
penpen