Can anyone help on extending a command.
Moderator: DosItHelp
Can anyone help on extending a command.
Hi
I have the following command of which at present it looks for a specific folder and then 7 ZIP's it up
7-Zip: 7za a –tzip "archive folder name" "source folder name"
What im trying to do is look in C:/Downloads for any unzipped folders and then zip it asking me for a password too if possible and then saving as a zipped folder in c:/Downloads
If possible too when it creates a new folder can I then automatically delete the UNZIPPED one.
The other issue that I will have there will already be zipped folders in "C/Downloads" so if they are already zipped and password protected I need them left alone and when zipping the folders all the folders will be named differently within C:/Downloads
Any Ideas
Thanks
I have the following command of which at present it looks for a specific folder and then 7 ZIP's it up
7-Zip: 7za a –tzip "archive folder name" "source folder name"
What im trying to do is look in C:/Downloads for any unzipped folders and then zip it asking me for a password too if possible and then saving as a zipped folder in c:/Downloads
If possible too when it creates a new folder can I then automatically delete the UNZIPPED one.
The other issue that I will have there will already be zipped folders in "C/Downloads" so if they are already zipped and password protected I need them left alone and when zipping the folders all the folders will be named differently within C:/Downloads
Any Ideas
Thanks
Re: Can anyone help on extending a command.
I think that I may be complicating things.
Another way I can do it is to set up 7-Zip: 7za a –tzip "C:/Downloads " "C:Downloads" and then move the zipped file to another file called C:/COMPLETED ZIPPED DOWNLOADS but I would still need the password to be input and protected before moving.
I think that would be easier can anyone help on a script for that ?
Thanks
Another way I can do it is to set up 7-Zip: 7za a –tzip "C:/Downloads " "C:Downloads" and then move the zipped file to another file called C:/COMPLETED ZIPPED DOWNLOADS but I would still need the password to be input and protected before moving.
I think that would be easier can anyone help on a script for that ?
Thanks
Re: Can anyone help on extending a command.
Just use the switch "-p" without setting it and 7-Zip will prompt you for the password:
For more information use "7z.exe -?" or see:
https://sevenzip.osdn.jp/chm/cmdline/
penpen
Code: Select all
"C:\Program Files\7-Zip\7z.exe" a "archive.zip" -m"em=ZipCrypto" "*.txt" -p
https://sevenzip.osdn.jp/chm/cmdline/
penpen
Re: Can anyone help on extending a command.
Sorry penpen you confused me. Where do I put that command? its just you saying abut C:/ program files and im talking about C:/ downloads.
All im trying to do it is to set up 7-Zip: 7za a –tzip "C:/Downloads " "C:Downloads" and then move the zipped file to another file called C:/COMPLETED ZIPPED DOWNLOADS but I would still need the password to be input and protected before moving.
All im trying to do it is to set up 7-Zip: 7za a –tzip "C:/Downloads " "C:Downloads" and then move the zipped file to another file called C:/COMPLETED ZIPPED DOWNLOADS but I would still need the password to be input and protected before moving.
Re: Can anyone help on extending a command.
"C:\Program Files\7-Zip\7z.exe" is the default location of 7zip, you need 7zip to do anything with it, so you need to tell your program which program to run. that would be "C:\Program Files\7-Zip\7z.exe" by default or whichever directory you installed 7z.exe.
You say to set up 7za, penpen is talking about 7z.exe these are two different programs ! You don't need to move any zipped files if you tell 7zip to create the archive in the desired directory. Penpen said the -p makes 7zip prompt you for the password, without verifying I assume penpen is correct.
Re: Can anyone help on extending a command.
Got ya
Really sorry as dos things to me are over my head.
Do I copy that txt into a notepad and save as a .exe or .cmd file?
Really sorry as dos things to me are over my head.
Do I copy that txt into a notepad and save as a .exe or .cmd file?
Re: Can anyone help on extending a command.
Sorry for confusing you, i had not much time, so i've tried to write short postings.
"7z.exe" and "7za.exe" should share the above options and command line switches, so this should also work (for the actual version):
I'm also unsure if you are using Windows (because you are using a slash instead a backslash in your pathes; for example in "C:/Downloads").
In case you are using windows the following batch script "test.bat" might help you (assuming "7za.exe" could be called directly from your command line; as your OP implies):Note that this batch doesn't delete any files (but you may add it if you want using the "rd" command - if the rest of your script does what you need).
Hope the above does help you.
penpen
Edit: Wrong path; changed 'if not exist "%%~na.zip"' to 'if not exist "C:\COMPLETED\%%~na.zip"'.
"7z.exe" and "7za.exe" should share the above options and command line switches, so this should also work (for the actual version):
Code: Select all
7za a "archive.zip" -t"zip" -m"em=ZipCrypto" "*.txt" -p
In case you are using windows the following batch script "test.bat" might help you (assuming "7za.exe" could be called directly from your command line; as your OP implies):
Code: Select all
@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
)
)
Hope the above does help you.
penpen
Edit: Wrong path; changed 'if not exist "%%~na.zip"' to 'if not exist "C:\COMPLETED\%%~na.zip"'.
Re: Can anyone help on extending a command.
Ive tried that script but I think that I have a problem with my 7 Zip.
Donno if anyone knows but I click on the file command on the desktop and it flashes as if something happening but nothing does.
You all mention 7za but cant find that anywhere in my 7 zip program
Donno if anyone knows but I click on the file command on the desktop and it flashes as if something happening but nothing does.
You all mention 7za but cant find that anywhere in my 7 zip program
Re: Can anyone help on extending a command.
I had a bug in my above script, but that should only lead in always creating a zip in your target folder "C:\COMPLETED\" per subfloder in "C:\Downloads\".
But that is not your issue, because you would have been prompted for a password if any folder was zipped.
You should open a command shell ("cmd.exe"), and change the path to your desktop.
After that type in the name of your batch file and hit enter.
You could copy the content of the shell and paste it to your next post (please use code tags around your code):
If "quick edit mode" is not enabled, then first click the right mouse button somewhere at the command shell.
Then (no matter which mode) push down the left mouse button onto a corner of the area you want to mark,
move the mouse until everything you like is marked, and then release the left mouse button and hit the ENTER-key.
Pasting to the post editing area within your browser is done by pressing the combination CTRL+V.
If i have to guess, then i think, that the command shell don't know the path of your 7-Zip standalone executable.
You may add it to my above script; make sure you use default doublequotes around the complete path if the path contains any space characters - should look similar to my first reply.
penpen
But that is not your issue, because you would have been prompted for a password if any folder was zipped.
You should open a command shell ("cmd.exe"), and change the path to your desktop.
After that type in the name of your batch file and hit enter.
You could copy the content of the shell and paste it to your next post (please use code tags around your code):
If "quick edit mode" is not enabled, then first click the right mouse button somewhere at the command shell.
Then (no matter which mode) push down the left mouse button onto a corner of the area you want to mark,
move the mouse until everything you like is marked, and then release the left mouse button and hit the ENTER-key.
Pasting to the post editing area within your browser is done by pressing the combination CTRL+V.
If i have to guess, then i think, that the command shell don't know the path of your 7-Zip standalone executable.
You may add it to my above script; make sure you use default doublequotes around the complete path if the path contains any space characters - should look similar to my first reply.
penpen
Re: Can anyone help on extending a command.
PenPen I get this come up...
C:\Users\g\Desktop>7za a "archive.zip" -t"zip" -m"em=ZipCrypto" "*.txt" -p
'7za' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\g\Desktop>7za a "archive.zip" -t"zip" -m"em=ZipCrypto" "*.txt" -p
'7za' is not recognized as an internal or external command,
operable program or batch file.
Re: Can anyone help on extending a command.
Then you have to add the path to '7za'; if "7za.exe" is in folder "C:\foo\doo", then you have to use "C:\foo\doo\7za.exe".
penpen
penpen
Re: Can anyone help on extending a command.
Ladies and Gents
My sincere apologies but its all above my head now as far as writing scripts etc.
I have the following script below that 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.
Would anyone be able to write me a script please please.
Thanks
My sincere apologies but its all above my head now as far as writing scripts etc.
I have the following script below that 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.
Would anyone be able to write me a script please please.
Thanks
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.Popup "All files moved.", 0, "Done", vbInformation Or vbSystemModal Or &h00040000&
Last edited by Squashman on 17 Apr 2018 06:11, edited 1 time in total.
Reason: MOD EDIT: Please use code tags.
Reason: MOD EDIT: Please use code tags.
Re: Can anyone help on extending a command.
Why the switch to VBscript?
Re: Can anyone help on extending a command.
Dont have to be a VB script. Anyway dont matter if that helps. its just what I posted was a VB script and thought that the only way.
Re: Can anyone help on extending a command.
You have already been shown how to zip the folder and password protect the folder. What are you not understanding from the previous help you have been given.