Skip to main content

Creating multiple folders and subfolders


The task was to create a set of folders say 1,2,3,4 and in each of these four folders create four sub folders.
Thus 16 folders were to be created and in each of these 16 folders a common set of files were to be copied.
I used c shell scripting to do the job. I needed two lists. One list for primary folders

list1:
1
2
3
4

and another list for the subfolders.
list2:
5
6
7
8

It worked as:
-------------------

bash-3.2$ csh
r410comp2%
r410comp2%foreach f (`cat ../list1`)
foreach? echo $f
foreach? mkdir "$f"
foreach? cd "$f"
foreach? foreach g (`cat ../../list2`)
foreach? echo $g
foreach? mkdir "$f"_"$g"
foreach? cd "$f"_"$g"
foreach? cp /home/kjoshi/W/work/complex/2_ion/umbrella/6/6_75/u_6_75.in .
foreach? cp /home/kjoshi/W/work/complex/2_ion/umbrella/6/6_75/amber11_intel_ref_md .
foreach?cp /home/kjoshi/W/work/complex/2_ion/umbrella/6/6_75/2_ion.inpcrd .
foreach?cp /home/kjoshi/W/work/complex/2_ion/umbrella/6/6_75/2_ion.prmtop .
foreach?cp /home/kjoshi/W/work/complex/2_ion/umbrella/6/6_75/dist.RST .
foreach?cd ..
foreach?end
foreach?cd ..
foreach?end

---------------
Thus it created folders with names like
main folder : 4
subfolders: 4_5
            4_6
            4_7
            4_8

and so on for other main folders.
All these subfolders contain the required files copied from some location

I then had to rename a particular file in each of these subfolders in particular format.

File to be renamed :u_6_75.in
                         to:     u_4_5.in, u_4_6.in etc
So I did this:

-----------------

r410comp2% foreach f (`cat ../list1`)
foreach? echo $f
foreach? cd "$f"
foreach? foreach g (`cat ../../list2`)
foreach? echo $g
foreach? cd "$f"_"$g"
foreach? mv u_6_75.in u_"$f"_"$g".in
foreach? cd ..
foreach? end
foreach? cd ..
foreach? end
---------------

So these files were renamed as u_4_5.in, u_4_6.in etc.



Worth time saving

Comments

Popular posts from this blog

AutoDock Vina protocol: For Molecular Docking

There are many softwares available for carrying out molecular docking calculations. Many of these softwares are paid, while some of them are free. AutoDock is one such freely available software. Earlier, there was AutoDock 4.0 version available. One of the problem with the software was the space it would occupy, if you attempt to do multi docking. Recently, there is another algorithm made available under autodock. It is called AutoDock Vina. This is more efficient, robust and fast algorithm. There are many tutorials available to learn AutoDock Vina including: http://autodock.scripps.edu/faqs-help/tutorial/using-autodock-4-with-autodocktools/2012_ADTtut.pdf and also a video tutorial http://vina.scripps.edu/tutorial.html    But for some reason, few changes or explanation in little detail is always required to make it understandable for a beginner to follow.  Here is a protocol designed in our group, which our Master's student follow to get acquainted to Molecular Docking s

Material Studio - selective molecule movement

So, working with Material Studio is awesome. You get to handle bigger, complicated and even unimaginable system. But I am facing problems in very minute functioning. I recently faced two problems, but managed to resolve on my own. Somehow, tutorials doesn't help in resolving them and you end up doing some exercise on your own to get the solution. Among these, the problem of bringing two molecular structures in one window and then adjusting one molecule by moving it around, while other structure remains untouched, as it is. Actually, this should not be a problem to do. There is a simple way of doing this. Select the molecule to be moved and then there is a symbol (button) to select, which allows you to selectively move that molecule only. This is the same way it can be done in Material studio too.  But among all the dozens of symbols, the new person handling MS, kind of gets lost. So, what he does is check the tutorials, for any help. But the tutorials don't talk about suc

xleap to generate prmtop and inpcrd files

Now that we have the lib file with the information for all the molecules we need to include and also the corresponding combined pdb file, creating prmtop and inpcrd files should not be a difficult task. So, to begin with we have a lib file name: molecule.lib a pdb file for 4 molecules name: four.pdb The  task is to generate a prmtop and inpcrd file. Initiate xleap using: $AMBERHOME/exe/xleap -s -f $AMBERHOME/dat/leap/cmd/leaprc.ff99 In xleap window > source leaprc.gaff # load the lib file by: > loadoff molecule.lib I am not sure but some times it helps to also load the frcmod files we created for the four molecules the information of which is stored in the lib file. > loadamberparams aldehyde.frcmod # Load the pdb file: > P=loadpdb four.pdb You should see some thing like this in the xleap window now: ------------------- > P=loadpdb four.pdb Loading PDB file: ./four.pdb Warning: name change in pdb file residue 1 ;  this residue is split i