Is there a way to modify the path for ".." ( shortcut )? - matlab

Whenever I download repositories from my team from other departments they have scripts ( .m files )in MATLAB which are runned from a path file which contain ".." ( like a shortcut ) in their path link and I do not know how to change that on my MATLAB workstation, the parent directory for it. For example an .m file (script) which contains:
MODEL_CONFIG='..\03_config\config.m';
run(MODEL_CONFIG)
On their workstation this code works but on my workstation it says that:
"there is no ..\03_config\config.m not found."
and I know that the ".." is the parent directory from the project. My question is:
"How can I change the default parent directory so that ".." can work on my workstation too?
Right now the only solution is to manually change in every script file the ".." with 'C:\Users%user%\Desktop\19_projectsMatlab\99_GSM_OEM' - and it this example 99_GSM_OEM would be the parent directory.

What a .. means in a path is basically: go back one folder from your current working directory in Matlab. You can easily change this folder by clicking on in Matlab.
If you want to change this folder during script execution you can do this with
cd 'C:/Users/yourname/yourfolder/'

Actually I am stupid. ".." is like "cd.." in MS-DOS....
I was in the wrong folder all the time. I am not supposed to be in the parent directory of the project when I run the main script. I am supposed to be in the folder directory where the main script is running (main.m).
So when I am in the folder directory of the main.m file the following link:
MODEL_CONFIG='..\03_config\config.m';
says go back with one folder from where the main.m file is and there should be the folder 03_config which you access. Thank you guys.
And if you have more subfolders in the folder in which is the main.m script "." - means the current location....

Related

Find path from where .exe is run Autohotkey

I have a compiled ahk script in which I use %_A_WorkingDir% to get the current working directory. But now I'm calling the .exe from another file two folders up so %_A_WorkingDir% returns the directory that is two folders up, not the location of the actual .exe. How do I fix this issue?
A_WorkingDir is the directory in which the script is currently
working. You can change it by using
the command SetWorkingDir.
A_ScriptDir is the full path of the directory where the script is in.
A_ScriptFullPath is the full path of the current script.
https://autohotkey.com/docs/Variables.htm#prop

command prompt: how would you move subfolders to parent folder?

I want to move whole folders instead of files inside the subfolder. I tried MOVE command but I can only move files. Is there any other command?
Assuming you're on Windows:
You may need to move the contents of the folder to another folder:
To move one or more files:
MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination
example:
move c:\windows\temp\*.* c:\temp
Move the files of c:\windows\temp to the temp directory in root, this is of course assuming you have the Windows\temp directory. In this example, . is wildcards telling the computer every file with every extension.
Source: http://www.computerhope.com/movehlp.htm
Alternately, this SO question's answers may help you: Command Prompt: Why do I get “cannot find the path specified” when I move a folder (with contents) from the desktop to a new directory?

How do I copy a file from my desktop, to another directory not on my desktop?

In my Desktop directory, I have a file called "ex12.txt"
I want to copy it and move it to another directory named "temp" in another location.
I've tried this:
Jahvons-MacBook-Air:desktop jahvonashmeade$ cp ex12.txt temp/
Then I get this
cp: directory temp does not exist
What exactly am i doing wrong?
EDIT: Never mind guys I found out the problem. I was skipping the root folder in the path directions.
copy/paste by chance. Seems fairly simple and easy to do

Accessing folders via MATLAB

I am trying to access some .m folders that I have downloaded into Downloads. How can I access this folder and run the files using cd similar to how I would on a Terminal (MacOS)? The same statements don't work.
All of the regular commands for linux should work.
ls, dir, cd 'your folder goes here' , cd ,, , cd.. etc
You need to pass the absolute path of your Downloads folder, e.g.:
current_dir = pwd;
cd('C:\Users\you_username\Downloads')
Then, you'll be able to access the files in that folder. When you are finished, you can then return to your original folder with:
cd(current_dir);
An alternative is to add the Downloads folder to your MATLAB path with addpath. You should then be able to access files in there from any directory of your choosing without having to cd. If you want to make that change to the MATLAB path permanent, use savepath afterwards to save the MATLAB path for future sessions.

Switching Files Between Directories with CUI (mv command)

I am currently working through "The Command Line Crash Course" and am having trouble switching files to my desktop.
In the terminal I create a new file (awesome.txt).
I see awesome on my desktop and then I make a directory (something).
I then do:
mv awesome.txt something/
When I open the something directory in my GUI, the awesome.txt is present. Now I want to take the awesome.txt and put it back on my desktop screen. So I try the same command and format I used to get it into the something directory
mv awesome.txt desktop/
I get an error "mv: rename awesome.txt to desktop/: No such file or directory"
NOW i found this command online, and it takes awesome.txt and puts it back on my desktop from the something directory
mv awesome.txt ../ (it moves it back to the last directory it is in)
Can anyone explain why I can't use the name desktop/ to put it back on my desktop screen? Is the desktop classified as something different than a file or directory?
Thanks!
The problem is that the name "desktop/" refers to a directory called desktop that's inside your "something" directory. But the actual desktop folder is outside of your "something" directory, so you need to tell mv to look there instead.
From the something directory desktop/ is relative to that directory, so it would be looking for something/desktop/ which obviously doesn't exist.
../ just means drop back a level, which is the desktop from the something directory.
you could try /desktop/ from the something directory, but you may want to try cd /desktop/ first to see where it takes you in case /desktop is not the actual root.