How to locate a file in command prompt without having to direct to the specific folder - windows

There must be a more effecient way to this, why can't I just type in the files name in the command line and expect the computer to find it? Right now I'm just paddling back and forward with the 'CD' and 'CD ..' commands.

You can use the following command which searches for the file in command prompt.
dir package.json /s

You can Use command find -path *content/docs/file.xml to find out the file.If it works please inform me the same.Thanks

Related

use the zip command specifying different path from current directory

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

Cannot change directory in psql on windows 10. PostgreSQL 11

I downloaded local PosgreSQL 11 on Windows 10.
I try to change directory in psql on command line window to c:\Program Files\PostgreSQL\11\bin>
I get either invalid command or directory does not exist
I tried following with
postgres=# cd c:\Program Files\PostgreSQL\11\bin
Invalid command \Program. Try \? for help.
postgres-# \cd c:\Program Files\PostgreSQL\11\bin
Invalid command \Program. Try \? for help.
postgres-# \cd..
Invalid command \cd... Try \? for help.
postgres-# \cd ..
postgres-# \cd Program Files
\cd: could not change directory to "Program": No such file or directory
I'm not even sure about current directory as pwd is not recognized:
postgres-# \! pwd
'pwd' is not recognized as an internal or external command,
operable program or batch file.
many thanks in advance
UPADATE: Figured out how to check current directory \! cd
Tried to run command this way \! C:\>cd C:\Program Files\PostgreSQL\11\bin
I get:
postgres-# \! C:\>cd C:\Program Files\PostgreSQL\11\bin
Access is denied.
A bit late for OP, but here are some tips for others who stumble in here.
There are two relevant psql commands for these directory change and drive change tasks.
The "built-in" \cd command. You can use this to actually perform the change of directory. However, where Windows uses backslash, use instead forward slash. Also, this command understands drive letter, and unlike Windows cd, you don't have to add a flag to change drive with the cd command here. Examples:
\cd /dir1/dir2
\cd D:/dira/dirb <-- Drive letter
\cd '/dir with spaces/other dir' <-- single quotes
Problem: How do you display the current drive/directory? Unlike in Windows, if you issue a \cd with no argument, psql does not show you the current directory. Instead it changes to the root C:\ directory (presumably in analogy to linux cd command changing to home directory.) So you need to issue a different command to see current directory.
psql can call a shell command, using the form \! <command>
So in linux you could use \! pwd to view present working directory. However, Windows doesn't have a pwd command. But you could use \! cd.
This is apt to get confusing, and prone to accidentally using \cd (which changes the directory unwantedly) when you intended ! cd, especially if you're jumping between Windows and Linux. So on Windows you might want to create a batch file to implement pwd.
As a further point of confusion, you might think to use something like:
\! cd \dira\dirb , however, for some reason, running \! cd with arguments doesn't seem to work (forward or back slashes).
An additional alternative, if you only need to change to a particular current directory once, you could cd before running the script that launches psql. That is to say, don't use the "SQL Shell (psql)" command that Postgresql installs on the Start Menu. Instead, look at the properties of that command, note the path to the script, and use that in a command window only after you've cd'ed to the desired directory.
You could try
postgres=# \cd 'c:\\Program Files\\PostgreSQL\\11\\bin'
I'm using windows btw
You have to change your directory before you run psql
Now, you might be thinking but when I open psql shell Its already running psql that's because you opened it in psql shell, don't do that
Here's what you need to do
open command prompt
change your directory using cd
then run the psql command
if you are getting 'psql is not a command' error, that is because the psql path is not in your environmental variables
if you need to fix that go to this page..→ Click me

CD command is not working

I am unable to change directory to a path stored as a variable value.
cd %VBOX_INSTALL_PATH%
If I input the command at the cmd.exe prompt it's working, but the same is not working in a batch file.
It's printed as:
cd C:Oracle/vbox
C:Oracle/vbox Not a valid directory path
Kindly help me to resolve it.
The CD command looks like this: CD C:\Oracle\vbox So if the error message is cd C:Oracle/vbox;C:Oracle/vbox Not a valid directory path Kindly help me to resolve it. I assume the content of %VBOX_INSTALL_PATH% is not C:\Oracle\vbox but something else. There is at least a \ missing right after C:. Further, this will only work as you expect if you are already on drive C:. If you want the command to work from everywhere, you should add the /D parameter:
SET "VBOX_INSTALL_PATH"="C:\Oracle\vbox"
CD /D %VBOX_INSTALL_PATH%
And by the way, / is the regular path separator for LINUX. For Windows, it is \. Windows will often accept / but in some cases, it might cause trouble.

Specific characters in command line

I am working in cmd and I found a symbol that I am not sure for what reason is used. Why do we use "~/" in command line.
Specifically in that case:
cp -R modules/swagger-codegen/src/main/resources/htmlDocs2 ~/templates
Thank you!
~/ is short term for your home directory
~username/ is short term to username's home directory
Many times while coding you need to pass the whole path of the file in cmd.
So it is just a shortcut to let the command line know that file is in the home directory itself.

How do I run bash shell scripts in cygwin?

I have a file called butcher and at the top of this file I put #!/bin/bash. The I changed permissions like so chmod 777 butcher. however when I try to run the script by typing butcher, I get this error: -bash: butcher: command not found. I'm not sure how to fix it, please help! Thank you in advance! :D
The file would have to be on your $PATH for your system to find it and execute it. Otherwise, the entire path to the file would have to be specified.
To show your path try:
echo $PATH
To run your script, either put it in one of those locations (such as /usr/local/bin), or go to the directory butcher is located in and run ./butcher.

Resources