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

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...

Using Packmol

Packmol is a software that allows you to generate a single combined PDB file for all the molecules you are considering. It is a free software and can be downloaded from this link: http://www.ime.unicamp.br/~martinez/packmol/ The installation guide is also provided on the page and its really easy to follow. http://www.ime.unicamp.br/~martinez/packmol/ You can also find some examples but I tried on my own. Anyway what you need is an input file which looks like: ------------------ tolerance 2.0 output trial.pdb add_amber_ter filetype pdb structure 2a.pdb   number 1   inside cube 0. 0. 0. 10. end structure structure 2d.pdb   number 1   inside cube 0. 0. 0. 10. end structure --------------------------------- IT includes some information like: how close the molecules considered can be.(tolerance) name of output pdb file "add_amber_ter" adds term "TER" after every molecule thus defining the start and end of every molecule. After mentioning the...

How would COVID bahave in August - few projections

Entering August with COVID by side   Entering in the month of August, COVID is still here by our side. Situation seems grim, worse than earlier, as number of active cases as well as the count of deceased patients are increasing day by day. Yesterday we crossed the mark of 50,000 cases in a day. Closely competing with Brazil with US counts also in range now. On the other side, few other numbers like reduced mortality rate to 2.18%, recovery rate of 64.6% and slightly increased doubling rate of 21 days can reduce the anxiety. My projections of 16.75 lakhs for India might be crossed by coupe of thousands of more cases after today’s count is added. This number would reach to a huge count of 28.5 lakhs by August 15. Maharashtra just doesn’t like competition. Just like what Delhi tried few days back, Andhra Pradesh also managed to cross Maharashtra’s per day count for2 consecutive days. Seems like not a good idea. Maharashtra immediately went to the next zone. The state which w...