LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-09-2011, 08:04 AM   #1
meet10may
LQ Newbie
 
Registered: Aug 2011
Posts: 9

Rep: Reputation: Disabled
Bash script to make 100 directory recursively with different names..


Hi,
In some data processing task, i need to rearrange my data.I have my raw data in a directory(eg. c:/Data).The data is present in different directories like (eg C:/Data/Data1,C:/Data/Data2,C:/Data/Data3..).I have 100's of such data.I need to keep the processed data in (D:/New_Data) with respective names of the raw data(eg. D:/New_Data/Data1 will contain processed data from C:/Data/Data1 and D:/New_Data/Data2 will contain processed data from C:/Data/Data2 and so on..).I need to make a bash script so that it automatically creates new empty directories in the D:/New_data with similar names as in C:/Data, so that i only need to specify the path of processed data. Please help me out with such Bash script.

Thanks
 
Old 08-09-2011, 08:19 AM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
Not sure if that will work with bash but if you use cmd scripts:
Code:
@echo off
pushd C:\Data
if not exist D:\New_Data\nul mkdir D:\New_Data
for /f "delims==" %%a in ('dir /b/ad/oen') do if not exist "D:\New_Data\%%a\nul" mkdir "D:\New_Data\%%a"
popd
 
Old 08-09-2011, 08:27 AM   #3
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,620

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Try this in bash:
Code:
cd /path/to/olddir
find . -type d -exec mkdir -p /full/path/to/newdir'{}' \;
 
Old 08-09-2011, 10:43 AM   #4
meet10may
LQ Newbie
 
Registered: Aug 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
Thanks a ton..it worked..it saved hell lot of time..
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you make custom directory names? daweefolk Linux From Scratch 7 04-15-2010 01:45 PM
[SOLVED] bash calling recursively a script patolfo Programming 8 03-29-2010 12:38 PM
Bash script to transfer folders recursively without overwriting via FTP laurens Linux - Newbie 9 11-13-2009 08:40 AM
[SOLVED] Script: Trim all file names recursively Flukester Linux - Server 9 10-28-2009 07:37 AM
Getting directory names from a given path in Bash? ojha_riddhish Programming 10 04-13-2009 06:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration