This question already has answers here:
How can I set a shorthand alias for a variable?
(2 answers)
Closed 6 years ago.
Trying to store some long pathways shortcut for all-time usage
for example Im often skipping to
cd C:\Users\xx\Dropbox\yy\folder_name
and I first tried to store it with New-Alias command like:
name: dropbox
value: cd C:\Users\xx\Dropbox\yy\folder_name
(also tried just the path way i.e C:\Users\xx\Dropbox\yy\folder_name)
But it won't work.
I've also created a profile and tried to edit the .ps1 file with:
New-Item alias:dropbox -Value "Set-Location \C:\Users\xx\Dropbox\yy\folder_name"
but this won't work either "search-path not correct" or something.
Anyone have an easy solution?
You could use a script like this:
if($args[0] -eq "dir1")
{
cd c:\projects\myProject
}
If you name it "ccd.ps1" and put it in your path, it should work to just type "ccd dir1"
At least it's a simple, understandable solution...
With mine I actually use a lookup in a config file with a dozen or so paths and shortcut names, but most people wouldn't mind just editing the .ps1.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I already know what it does: It simply goes one directory or folder backwards.
But what's mysterious for me are those two dot.
cd.. #it has the same function as popd with the difference that it changes the
#current working directory
If someone tell me what is the philosophy of putting those two Dots, i would really appreciate it.
.. in filesystem paths represents a given path's parent path.
Without an explicit path preceding the .., the implied path is the current [working] directory, so the .. therefore refers to the current directory's parent directory.
In short: cd with an argument of .. changes to the current directory's parent directory, i.e., the directory one level above in the directory hierarchy.
Shell-specific use of .. with cd:
The legacy command processor, cmd.exe ("Command Prompt") - seemingly with the internal cd command specifically (see Mofi's comments on the question) - considers an . character to implicitly start the cd command's argument.
Therefore, separating the cd command from the .. argument with a space character, as usual, isn't necessary; that is, instead of cd .. you can type cd.., which is a shortcut that users of cmd.exe have grown accustomed to over the years.
PowerShell allows . characters to be used in command names, so submitting cd.. does not invoke the cd command (a built-in alias for the Set-Location cmdlet) with argument .. - instead, it looks for a command literally named cd..
To accommodate cmd.exe users who are accustomed to the cd.. shortcut, PowerShell comes with a parameter-less function literally named cd.., so that submitting cd.. as a command in PowerShell effectively works the same as in cmd.exe.
However, note that only cd.. works, not also specifying additional components; that is, something like cd..\Foo (which works in cmd.exe) fails.
Get-Command cd.. | Format-List shows information about this function, which reveals that it simply calls Set-Location .., which is PowerShell's equivalent of cmd.exe's cd ..
These two dots mean "One upper level in the directory".
cd specifies to change the directory and .. means "upper level". So, cd.. means exactly what you stated in your question.
Example: let's say you are in the folder C:\x\y. If you type cd.., you'll be on C:\x
This question already has answers here:
Access m-files in a subfolder without permanently adding it to the path
(2 answers)
Closed 7 years ago.
I'm working on a project containing some subprojects. Each subproject is located in a own folder.
projDir/subProj1
/subProj2
and so on. Each subproject is a standalone running project. But now I want to use some functions of i.e. subProj1 in subProj2. But the functions in subProj1 should not be visible in general. So it is no good idea, to add the subProj1-path to the MATLAB-Path generally. Hence, I want to add this path in my .m-file stored in subProj2 and after finishing this script, the path should be removed (automatically) by it's own. Is there any possibility, to add a path temporarily to the MATLAB-path variable?
The addpath function only adds the files/folder to your path for the current Matlab session, assuming you don't call savepath. You also might find the genpath function helpful if you want to add subfolders.
You can use path(path_to_add,path) to add a path to the current path variable. Unless you do savepath you won't affect the global path.
I would do path(strcat(pwd,'\subProj1',path) etc. in the config .m script you have.
This question already has answers here:
Trying to download a zip file from a weblink with powershell
(1 answer)
PowerShell -WebClient DownloadFile Wildcards?
(3 answers)
Closed 9 years ago.
I am working on a script to download a series of files from a http location to a local directory. The filename consists of a time and date stamp as well as a static string. As far as I know, I have to have the exact filename when downloading using System.Net.Webclient, which is where I have an issue.
Is there either a wildcard method to use in System.Net.Webclient, or is there a way I can capture and parse the directory listing as it appears when I go to the parent directory in a browser?
The filenames are as such...
FLASH_20131112_203721_WEEKLYFY_C.dat.gz
The first numerical portion is a date, the second portion is a timestamp.
This question already has answers here:
Pycharm utils.py not getting syntax highlight
(6 answers)
Closed 3 years ago.
I am attempting to create a .rb file within Ruby, using these steps:
1. Create New File
2. Name new file "a"
3. Associate file to .rb filetype
This creates a file named "a" that works fine; however, when I rename this file to a.rb it immediately converts the file to a text file. Why is that?
I have been creating files this entire time by creating a new file and naming it "a.rb" from the start, and it automatically associates it to a ruby file. Now it just associates that naming to a text file and I have to leave off the .rb and manually assign the filetype later. What changed?
FOR MAC USERS you can find the settings you need to fix this here:
RubyMine | Preferences | Editor | File Types
The above answer is correct – removing a.rb does solve the problem – and I realize that this question is two years old now… But having come across this problem today and not having been able to find a solution for the longest time, hopefully this will help someone else too. Default Settings under File does NOT have this tab in the current version of RubyMine on Macs, and it took me forever to find the tab where File Types is.
This question already has answers here:
How to get all files under a specific directory in MATLAB?
(8 answers)
Closed 8 years ago.
I have my data in multiple folders. Let's say I have a folder containing 100 subfolders at the moment that look like this:
/folder/Re0001/vitesse
/folder/Re0002/vitesse
/folder/Re000N/vitesse
/folder/Re000N+1/vitesse
/folder/Re0100/vitesse
I want to import the vitesse file into a cell array. This is the code that i am using at the moment:
numfiles=100;
mydata=cell(1,numfiles);
for i=1:numfiles
mydata{i}=uiimport;
end
It is a working solution.
However, if it involves 100 or more files I have to specify each folders and files manually, which is very troublesome.
By the way I am new to Matlab so can you please incorporate example code with the directory given.
I did something similar few days ago. Have a look at the matlab function ls. If you are using windows system, you are all set. If your are using linux, you may need to split the results. However newer version of matlab have the strsplit function that will do the job, or you will use regular expressions.
In your case,
list = ls('/folder/*/vitesse');
will give you a list of your files.