Sponsored Content
Top Forums Shell Programming and Scripting Making 99 folders 99 folders deep Post 302517014 by YukonAppleGeek on Monday 25th of April 2011 09:53:45 PM
Old 04-25-2011
Making 99 folders 99 folders deep

I am trying to make a unix shell script that will make 99 folders 99 deep (counting the first level folders). So far i have made it make the first 99 folders and 99 more in all of the folders. The only problem is the only way i have found is copying and pasting part of the script over and over and over.

Here is code any suggestions:
Code:
#!/bin/bash
for num in {1..99}; do
    mkdir $num
    cd $num
    for num2 in {1..99}; do
	mkdir $num2
    done
    cd ..
done

Code for 3 folder levels
Code:
#!/bin/bash
mdir=$(pwd)
for num in {1..99}; do
    mkdir $num
    cd $num
    for num2 in {1..99}; do
	mkdir $num2
        cd $num2
        for num3 in {1..99}; do
	    mkdir $num3
        done
        cd ..
    done
    cd $mdir
done

Make 9 folders 4 deep (found at: *new so cant post url but google "10000 folders applescript" and it is the first link )
Code:
#!/bin/bash
mkdir 0
mkdir 0/0
mkdir 0/0/0
mkdir 0/0/0/0

for a in 1 2 3 4 5 6 7 8 9
do
for b in 1 2 3 4 5 6 7 8 9
do
for c in 1 2 3 4 5 6 7 8 9
do
for d in 1 2 3 4 5 6 7 8 9
do
cp -R 0/0/0/0/ 0/0/0/$d
done
cp -R 0/0/0/ 0/0/$c
done
cp -R 0/0/ 0/$b
done
cp -R 0/ $a
done
exit 0

EDIT: After making all folders have 3 levels it took 23 min so maybe not 99 deep configurable deepness if posable?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Backing up Folders without some folders...;)

I am in a fix....... I have to write a backup script to backup say Folder A. Folder A contains n folders 1,2 ,3 .....n. my script should copy A without folder 2 & 3. Is there anyway I can do it without writing individual copy commands???? Please help.... (1 Reply)
Discussion started by: chimpu
1 Replies

2. UNIX for Dummies Questions & Answers

Copying Folders without some folders... ;-)

I am in a fix....... I have to write a backup script to backup say Folder A. Folder A contains n folders 1,2 ,3 .....n. my script should copy A without folder 2 & 3. Is there anyway I can do it without writing individual copy commands???? Please help.... (5 Replies)
Discussion started by: chimpu
5 Replies

3. Shell Programming and Scripting

Renaming folders

Hello, I'm new to unix and I have to rename all folder fron the current folder from a name like "xx - Name of the Folder" to "Name of the Folder - xx". xx is a number ... Can somebody, please, help? Thank you! (6 Replies)
Discussion started by: mirciulicai
6 Replies

4. Shell Programming and Scripting

How to hide folders

hello everybody, i would like to hide visibility of the folders , i.e. not to giving any physically visibility to any users . Is there any way to do it other than changing the permission and adding "." post folder name . by changing the permission , we cann't do any activity , but have... (1 Reply)
Discussion started by: manas_ranjan
1 Replies

5. UNIX for Dummies Questions & Answers

Searching for folders/parent folders not files.

Hello again, A little while back I got help with creating a command to search all directories and sub directories for files from daystart of day x. I'm wondering if there is a command that I've overlooked that may be able to search for / write folder names to an output file which ideally... (2 Replies)
Discussion started by: Aussiemick
2 Replies

6. Solaris

Folders with more than one 'owner'

I have a peculiar problem. I have a particular directory with the following characteristics: -bash-3.00# ls -lah total 18 drwxr-x--- 7 gandalf shire 512 jul 3 07:20 . drwxr-x--- 11 gandalf shire 512 mai 10 2010 .. drwxr-xr-x 6 gandalf shire 3,0K jul 24 19:25 brasdeff drwxr-xr-x... (9 Replies)
Discussion started by: poyato
9 Replies

7. Shell Programming and Scripting

Copy between two different folders containing same sub-folders

I have a folder like this ls input1 dir1 dir2 dir3 file1 file2 file3 dir1, dir2 and dir3 are sub-folders inside the folder input1 ls input2 dir1 dir2 dir3 file1 file2 file3 My dir1 in input1 folder has files f1, f2, f3 and f4. My dir1 in input2 folder has file f4 and f5. ... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

8. UNIX for Dummies Questions & Answers

Archive folders and sub folders

Hi Can i archive folder and folders in with the tar command My files are located in subfolders Eg: Folder1/Folder1_1/*.pdf Folder1/Folder1_2/*.pdf Folder1/Folder1_3/*.pdf so i would like to tar all the files in Folder1_1 and Folder1_2 only not Folder1_3 that should be done next... (2 Replies)
Discussion started by: cnrj
2 Replies

9. Shell Programming and Scripting

Exclude certain folders

Hi Experts, Below is my shell script and it will move the files older than 90 days to archive mount. Now my new requirement is , I need to move some of the directory files older than 365 days. How can I achieve this. Simply I have DIR1 DIR2 DIR3 DIR4 I need to exclude DIR 2 and DIR 2... (5 Replies)
Discussion started by: arumugavelvelu
5 Replies

10. Shell Programming and Scripting

How to copy files/folders and show the files/folders?

Hi, So i know we use cp -r as a basic to copy folders/files. I would like this BUT i would like to show the output of the files being copied. With the amazing knowledge i have i have gone as far as this: 1) find source/* -exec cp -r {} target/ \; 2) for ObjectToBeCopied in `find... (6 Replies)
Discussion started by: Imre
6 Replies
folders(1mh)															      folders(1mh)

Name
       folders - list folders and contents

Syntax
       folders [ +folder ] [ msg ] [ options ]

Description
       The command displays the names of your folders and the number of messages that they each contain.

       The  command displays a list of all the folders in your Mail directory.	The folders are sorted alphabetically, each on its own line.  This
       is illustrated in the following example:
	 Folder      # of messages (  range  ); cur  msg  (other files)
	   V2.3  has	3 messages (   1-   3).
	 adrian  has   20 messages (   1-  20); cur=   2.
	  brian  has   16 messages (   1-  16).
	  chris  has   12 messages (   1-  12).
	copylog  has  242 messages (   1- 242); cur= 225.
	  inbox+ has   73 messages (   1- 127); cur= 127.
	    int  has	4 messages (   1-   4); cur=   2  (others).
	   jack  has   17 messages (   1-  17); cur=  17.

		 TOTAL= 387 messages in 8 folders.
       The plus sign (+) after inbox indicates that it is the current folder.  The information about the folder includes the term (others).   This
       indicates  that the folder contains files which are not messages.  These files may be either sub-folders, or files that do not belong under
       the MH file naming scheme.

       The command is identical to the effect of using the -all option to the command.

       If you use with the +folder argument, it will display all the subfolders within the named folder.  as shown in the following example:
       % folders +test
       Folder		# of messages (  range	); cur	msg  (other files)
       test+ has	  18 messages (   1-  18);	     (others).
       test/testone has    1 message  (   1-   1).
       test/testtwo has   no messages.

	      TOTAL=   19 messages in 3 folders.
       See for more details of sub-folders.

Options
       -fast
       -nofast	 Lists only the name of folders, with no additional information.  This is faster because the folders need not be read.

       -help	 Prints a list of the valid options to this command.

       -list
       -nolist	 Lists the contents of the folder-stack.  No +folder argument is allowed with this option.

       -pack
       -nopack	 Re-numbers messages in the folders.  Messages are re-numbered sequentially, and any gaps  in  the  numbering  are  removed.   The
		 default operation is -nopack, which does not change the numbering in the folder.

       -pop	 Discards  the	top of the folder-stack, after setting the current folder to that value.  No +folder argument is allowed with this
		 option.  This corresponds to the operation in the C-shell; see The -push and -pop options are mutually exclusive: the last occur-
		 rence of either one overrides any previous occurrence of the other.

       -push	 Pushes  the  current  folder  onto  the  folder-stack, and makes the +folder argument into the current folder.  If +folder is not
		 given, the current folder and the top of the folder-stack are exchanged.  This corresponds to the operation in the  C-shell;  see
		 The  -push switch and the -pop switch are mutually exclusive: the last occurrence of either one overrides any previous occurrence
		 of the other.

       -recurse
       -norecurse
		 Lists folders recursively.  Information on each folder is displayed, followed by information on any  sub-folders  which  it  con-
		 tains.

       -total
       -nototal  Displays  only the total number of messages and folders in your Mail directory.  This option does not print any information about
		 individual folders.  It can be suppressed using the -nototal option.

       The defaults for are:

	      +folder defaults to all
	      msg defaults to none
	      -nofast
	      -noheader
	      -nototal
	      -nopack
	      -norecurse

Restrictions
       MH does not allow you to have more than 100 folders at any level in your Mail directory.

Profile Components
       Path:		 To determine your MH directory
       Folder-Protect:	 To set protections when creating a new folder
       Folder-Stack:	 To determine the folder stack
       lsproc:		 Program to list the contents of a folder

Files
       The user profile.

See Also
       csh(1), folder(1mh), refile(1mh), mhpath(1mh)

																      folders(1mh)
All times are GMT -4. The time now is 07:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy