use the zip command specifying different path from current directory - windows

We have a set of unix tools that were ported to windows and I want to use the zip command to package a set of files.
I'm trying to do this:
Open cmd from desktop and take the files in r:\pam\client\ssb\portfoliorepportcards\202003\*.docx and create a zip file in r:\pam\client\ssb\PortfolioReportCards\202003.zip with the files in it.
My command is:
C:\Users\JPalomino\Desktop>zip.exe -b "r:\pam\client\ssb\PortfolioReportCards" 202003.zip . -i r:\pam\client\ssb\portfoliorepportcards\202003\*.docx
zip error: Nothing to do! (202003.zip)
and I get nothing
However when I cd to r:\pam\client\ssb\portfoliorepportcards and do
R:\Pam\Client\SSB\PortfolioReportCards>zip -r 202003.zip . -i \202003\*.docx
it works like a charm. Also I wouldn't want the folder structure in it.
Could you please tell me what I'm doing wrong in the command? It seems such an easy thing to ask from zip.
Thanks

Maybe this will help, you don't need zip.exe (if you have powershell 5 or higher)...
powershell -command "Compress-Archive -Path 'r:\pam\client\ssb\PortfolioReportCards\*' 'r:\pam\client\ssb\PortfolioReportCards\202003.zip'"
I saw you're having trouble zipping to another drive letter, this should help with that too. I'm not really familiar with zip.exe to know why that's giving your grief.
Anything else you "port" to cmd is probably better off as a powershell. --- also if "zip.exe" isn't on your desktop that could possibly be your problem right there. If it works when you CD that tells me it's probably located where you're CD'ing to. Perhaps add zip.exe as an environment variable so that it can be accessed globally instead of only from the working directory.
And my take one your command (If zip is actually on your desktop or set as environment variable... : zip.exe -b "r:\pam\client\ssb\PortfolioReportCards" 202003.zip . -i r:\pam\client\ssb\portfoliorepportcards\202003\*.docx
I would re-write that and try this instead (because traditionally the filepath is all in quotes for any other windows command I know of)...
zip.exe -b "r:\pam\client\ssb\PortfolioReportCards\202003.zip" . -i r:\pam\client\ssb\portfoliorepportcards\202003\*.docx

Related

How to go to a specific file in Mac Terminal?

I'm trying to follow a walkthrough and this is one of the steps, "go to that same folder in Terminal (if you can't do that you should probably quit now)" I'm not very familiar with Mac's Terminal, but don't feel like quitting. If it helps, I need to run a grep -r "what I'm looking for" command on the file. I really have no idea what I need to do to run that command, but the rest of the walkthrough is pretty thorough, so I know I can follow the next few steps.
You need to move to the directory where that file is stored, for this the command is cd. For example lets say the file is located in a directory names MyDir in the Desktop, the command will be
cd /Users/{YOUR_USERNAME_HERE}/Desktop/MyDir
You can run ls command here to check if the file is actually present in this directory or not

How to open all mp3 files using windows command line?

If I have the following directory:
C:\Users\mkt\Desktop\Music\Tool\Lateralus
and want to open all files contained in the folder using cmd prompt. how could I do that?
I know that the following line will open one of them:
cd C:\Users\mkt\Desktop\Music\Tool\Lateralus\"01 - The Grudge.mp3"
But what about multiple files?
I am a noob at DOS and I really shouldn't be, but without practice you will never get better.
I am wondering, why it is opening your mp3 file with the cd command.
The cd command is used to switch directories, so this is something new for me.
I am a MAC OS user, so I could not test it, but if your given example worked, I think this should work too:
cd C:\Users\mkt\Desktop\Music\Tool\Lateralus\*.mp3
With the "*.mp3" you say, every mp3 file.
I hope this helps.

How to send a file to Desktop with bash script?

I am trying to send a file or folder to Desktop with Linux Command Prompt but I don't know how.
Please tell me what command can I use for this?
The move command mv. Use man mv for more information, as this command is a lot more complex than it seems. With cd Desktop/ you should be able to find your desktop on variations of linux like Mint or Ubuntu. To find your present working directory, as in your current path for the terminal, type pwd. This will give you your directory which will be similar to /home/Desktop.

How to change the copy file behavior in mac osx

I used to use Ubuntu
most of time, the command are same as Ubuntu
But there is a command annoys me.
it is cp (copy command)
because I often type cp -a FOLDER/ target
to copy a file , however , the command will copy all the folder under FOLDER/ but not including FOLDER/ itself.
I know I can get what I want by using cp -a FOLDER target (without the slash in the tail)
it easily to misuse the command.
Is there any way to change the behavior, thanks
The command cp is a program in /bin so you could rename the cp command to another file, such as main_cp.exe and create a batch file (script) of your own called cp, which changes the call from what you type to what is actually required and then calls main_cp.exe.
However, if you're going to be using OSX a lot and perhaps on other people's machines, learning to train yourself to just not type the slash is probably going to be better in the long term.

wget on Windows command line

Basically I'm trying to download images from a website using the following command (SwiftIRC is an easy example to use):
wget.exe -r -l1 -A.png --no-parent www.swiftirc.net/index.php
This command works fine, however one of the ways I am trying to do it isn't working.
When I fire up an elevated command prompt, default to windows\system32.
If I use to following two commands everything works fine:
cd c:\users\tom\downloads\\
wget.exe -r -l1 etc. etc.**
The images are saved in the folder www.swiftirc.net in my downloads folder.
However if I try to do this in one line like this:
c:\users\tom\downloads\wget.exe -r -l1 etc. etc.
The response from wget on the cmd is exactly the same, but the images are not saved on my hard disk.
Does anyone know what I'm doing wrong?
Try adding c:\users\tom\downloads\ to PATH or put wget.exe into your windows/system32 folder.
I beleive it's because windows doesn't allow users to write files on the disk root, when you run "c:\users\tom\downloads\wget.exe" you have C:\ as a working directory so the files should be saved there but it's not allowed by the common strategies

Resources