when I am trying to access files in sub folders of a main folder, How do I come back to main folder.
Ex: C:\Users\User1\Documents\MATLAB\folder1\folder2\folder3
How do I come back to folder2 to access another sub folder in folder2
You either save your current directory in a variable and cd there later, or you go up in the directory hierarchy by doing cd ..
To expand on the previous answer, could use the ..\ operator.
For eg, in order to read an image in folder4 (which is a sub directory of folder2), you can use this:
ex_img = imread('..\folder4\ex_img.jpg');
Related
I try make a script witch go through a directory and for each file in the directory it will make a zip archive copy the archive somewhere else and then extract the archive. In the end, the whole directory i copy from has to equal to the new directory somewhere else but in files were copied has archive.
i had a problem with going through all files in the directory because it has a lot of sub directories so i could not go through all of them with a simple for loop.
My plan was to copy first all the directories and sub directories "xcopy /t /e" and then go through the files and archive copy and extract each one of them individually but as i said earlier i could not do it.
If someone can help me and show me how to to go through files like that or how to accomplish my mission, it will be perfect.
Thank you.
You could use recursion for that. Both zip -r or rsync could do the job in a very simple way. You do not have to loop.
I have the folder called, SpartanDrive-hansol, as you see in the picture, and it contains all the necessary files that I need. But just the folder, SpartanDrive-hansol, is unnecessary, and it causes a problem when I try to merge it with master branch because master branch does not have that folder.
Can anyone help me how to delete the unnecessary hierarchy of the folder? (But I need all the files that are in the folder) Thank you!
You can do it easily with the terminal. In the parent directory of the SpartanDrive-hansol folder, run the following command in the terminal:
mv SpartanDrive-hansol/* .
This will move all contents of the folder to your current folder, which in this case is the parent folder.
I was create Project folder and Some sub folder that have solution under sub folders.
user A use solution A under sub folder A, user B use solution B under sub folder B (means that he map only folder b and work on it) and etc.
we have some common files that use on the all project (A,B,...) we can put them under the one folder for examople "Common" under the Project folder.
user A want to work with his project he get folder A but he need to Common folder files too. what to do?
like ewise user B want changes this file. and use to his project (B).
I want have automatic way to get external file with solution simultaneously.
To get the common files under the Common folder together with solution, you can consider using batch script which contains two tf get commands:
tf.exe get /recursive $/SolutionA
tf.exe get /recursive $/Common
When running this batch script, both SolutionA and Common folder are downloaded.
I do a backup of the files that need to be replaced as part of the installation. For this I use the above action. However, it just copies the files in the child directory to the destination directory but not the directory hierarchy of the source to the destination directory. Example: I have a some files in this directory structure \dir1\dir2\dir3\files. It copies only the files under dir3 but not the \dir1\dir2\dir3. I need to preserve the directory structure in the backup. Can anyone help with this please?
I am using Windows 7 Enterprise.
Thanks very much.
You have to select the root directory in the action, i.e. the one containing "dir1". Then, it will copy the whole directory tree to the destination.
If you want to copy only parts of the directory tree, use the "Directory filter" and "File filter" properties.
I would like to put directory C:\WorkDir under Mercurial version control, but have the repository located somewhere else than C:\WorkDir\.hg perhaps D:\Repositories\WorkDir.hg. Is that possible in Mercurial?
This answer on the Mercurial mailing list by Martin Geisler is quite clear about it:
You cannot move the .hg folder outside of where your working files
reside. That is by definition: the "working copy" is the parent
directory of the .hg folder. So if you want to version files in
C:\inetpub\laravel\app
you must have
C:\inetpub\laravel\app\.hg
If you want to avoid having the drive with the "real" working copy filled up with the repository data, you can use the share extension: https://www.mercurial-scm.org/wiki/ShareExtension .
E.g. if you want to version control C:\WorkingDir, but want the big repository data to reside on D:\Repositories\WorkDir, just do the following:
cd D:\Repositories
hg init WorkDir
cd C:\
hg share D:\Repositories\WorkDir WorkingDir
You will still have a .hg directory on C:, but it will remain really small (around 1MB), while the repo on D: will be the one that grows with time.
Have you tried creating a Junction?
Let's say your repo is c:\test\.hg but you want to put .hg directory in c:\shadow
mkdir c:\shadow
mv c:\test\.hg c:\shadow\.hg
mklink /j c:\test\.hg c:\shadow\.hg