Creating a sub-folder in multiple folders


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Creating a sub-folder in multiple folders
# 1  
Old 11-13-2014
Creating a sub-folder in multiple folders

Hi I've been trying to find an answer to this question and was hoping someone would be able to help me.

I want to add a sub-folder to to an existing structure: for example

Code:
/toys/toy_1/new
/toys/toy_2/new
/toys/toy_3/new

There are humdreds of theses folders - what i want to do is add a sub-folder to all the "new" folders called type.

so it would like like this
Code:
/toys/toy_1/new/type
/toys/toy_2/new/type
/toys/toy_3/new/type

Any help would be greatly appreciated.

Last edited by Corona688; 11-13-2014 at 02:25 PM..
# 2  
Old 11-13-2014
Use code tags for code and data, please. [code]stuff[/code] or select the relevant text and click the Image button.

Code:
find /toys -type d -path '*/new' -exec mkdir -p '{}/type' '+'

If your find doesn't support '+', use ';'.
# 3  
Old 11-16-2014
If you want to create the file only in empty directories:
Code:
 find toys -type d -empty -print0 | xargs -0 mkdir

or
Code:
 find toys -type d -links 2 -print0 | xargs -0 mkdir

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Looping through all folders in a folder.

I am trying to write a script that loops through all the folders within a given folder. My intention is to access each folder and rename each file ending with fna.gz with the name of the folder it resides in. #!/bin/bash cd /p/w/d/ for f in /p/w/d/*; do echo $f done I'm... (13 Replies)
Discussion started by: Mr_Keystrokes
13 Replies

2. Shell Programming and Scripting

Execute multiple files in multiple folders and also output on same folder

How to execute multiple files in multiple folders and also output to be generated in the same folder? Hello Team, I have a path like Sanity_test/*/* and it has around 100+ folders inside with files. I would like to run/execute those files and output of execution to be placed on same /... (1 Reply)
Discussion started by: pushpabuzz
1 Replies

3. Shell Programming and Scripting

awk creating folders

Hello, im trying to create folders from text file and i get errors :( #!/bin/bash awk 'BEGIN { RS = "/" } ; { mkdir $1, mkdir $2, mkdir $3, mkdir $4, mkdir $5}' zodziai.txt im new in linux stuff just trying to learn. The idea is i want to create new folders from words in text file. I... (4 Replies)
Discussion started by: boxstep
4 Replies

4. UNIX for Dummies Questions & Answers

Unzipping a file which has multiple folders and each folder has the files with same name in it

Hi, I have a zipped file a.zip. This has got multiple folders in it say x and y. x contains a.txt and y contains a.txt. Is it possible to unzip this file and have the 2 files extracted and rename them to unique names. Thanks in advance. (1 Reply)
Discussion started by: arunkesi
1 Replies

5. Shell Programming and Scripting

How to delete other's folders which are in our own folder?

Hi All, I need a solution for the following scenario. I am the owner for the particular folder and I have given 777 permissions for some specific reasons. So others can able to create folders and files. But when I am done with the work, I need to delete the folders which are created by... (4 Replies)
Discussion started by: manoj_thorali
4 Replies

6. UNIX for Dummies Questions & Answers

Tar-ing folders in a folder

How do I create individual tars of a all the directories in a directory? I have a directory called 'patients', each patient has a directory in the patients directory. I want to create tars such that each patient has their own tar file. Thanks! (5 Replies)
Discussion started by: HappyPhysicist
5 Replies

7. Shell Programming and Scripting

Find files of type within folder copy multiple results to different folders

Ok question number two: I'd like to search a directory for multiple file types (rar, txt, deb) and depending on what's found, copy those files to folders named Rar, TextFiles, and Debs. I'm looking for speed here so the faster the script the better. I want it to be a function that I pass 1 argument... (4 Replies)
Discussion started by: DC Slick
4 Replies

8. Shell Programming and Scripting

Using cp: preserving file/folder attributes and auto creating folders

Hi, Is there a way to use cp in such a way that when a file is copied to a destination, the required destination folders are automatically created with the proper permissions, and the resulting copied file has the same attributes as the original. For example if I copied... (1 Reply)
Discussion started by: pcwiz
1 Replies

9. Shell Programming and Scripting

Creating links to multiple folders

Hi All, First of all, I'm a unix newbie so don't be to hard on me :) I'm not even sure if the thing that I want is even possible but here goes nothing: On my linux based NAS I have the following structure: videos |---movie 1 |---movie 2 |---movie 3 | USBDISK |---videos |--- movie... (8 Replies)
Discussion started by: kvb
8 Replies

10. UNIX for Dummies Questions & Answers

Copying multiple folders to local machine (don't know folder names)

Hi. I'm trying to copy multiple folders from the remote machine to the local machine. I wrote a batch file to run an ftp window. The problem I am having is that the only command to copy files is mget *, and this copies only files, not folders. For example, ftp ts555 cd ts555/test ' test... (5 Replies)
Discussion started by: leenyburger
5 Replies
Login or Register to Ask a Question