Find folder within folder, then find other folder in same dir


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find folder within folder, then find other folder in same dir
# 8  
Old 01-27-2011
Code:
find /var/root/Applications/*/fooBar/Documents  -type f -name "*.rar" -exec cp -n -p -t {}  /to/my/directory/ \;

# 9  
Old 01-27-2011
No bash or ksh, do you have dirname:

Code:
for dir in /var/root/Applications/*/fooBar
do
    dir=`dirname $dir`
    [ -d "$dir/Documents" ] && find "$dir"/Documents -type f -name "*.rar"
done | xargs cp -n -p -t /to/my/directory/

@rdcwayx see post #5, also -t option of cp specifies the target directory
# 10  
Old 01-28-2011
Quote:
Originally Posted by rdcwayx
Code:
find /var/root/Applications/*/fooBar/Documents  -type f -name "*.rar" -exec cp -n -p -t {}  /to/my/directory/ \;

Documents is not a directory of fooBar. It's located in the same directory as fooBar. The reason I search for fooBar and not directory is because it is unique as all applications in the /var/root/Applications folder contain a Documents folder. I need to find the folder that has fooBar in it, then go to the folder named Documents which is also in it. Then I need to copy files from it once I've found it

---------- Post updated at 11:10 PM ---------- Previous update was at 08:14 PM ----------

Quote:
Originally Posted by Chubler_XL
No bash or ksh, do you have dirname:

Code:
for dir in /var/root/Applications/*/fooBar
do
    dir=`dirname $dir`
    [ -d "$dir/Documents" ] && find "$dir"/Documents -type f -name "*.rar"
done | xargs cp -n -p -t /to/my/directory/

@rdcwayx see post #5, also -t option of cp specifies the target directory
I've used dirname before so yes that is present. I will test this later Chubler thank you as always man.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

2. Shell Programming and Scripting

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies

3. UNIX for Dummies Questions & Answers

How to find from / but exclude certain folder?

:)Hi Unix Specialists, I need your advice on how to find all the files from root ( / ) filesystem but exclude those from /export/home (different filesystem) folder. Below are some of the find statements that I have tried without success: find / -name '/export/home' -prune -o print -ls ... (6 Replies)
Discussion started by: gjackson123
6 Replies

4. Shell Programming and Scripting

Find and Tar a Folder

Hi all, I have created a function that looks for a folder in a particular directory, checks the date it was last modified and if its old then compress it. This works fine for files using gzip. However for folders I had to use tar. This is my function: compressOldFolder() { # $1 is... (10 Replies)
Discussion started by: TasosARISFC
10 Replies

5. Shell Programming and Scripting

Find a folder from a directory

Hi, I have a folder name XX and a directory N:. Now I want to find the folder on that directory and print the path. I tried with grep "XX" N: but also search for files named as XX, but I want to find onlt folder and print. please help me.. Thanks in advance (12 Replies)
Discussion started by: arup1980
12 Replies

6. Shell Programming and Scripting

find the folder with space in name.

A solaris server with SAMBA share folder. The PC users created many folders with space on it, I want to find them out, but not list its subfolders. For example, I have below folders Copy of ABC/efg/xy sa/Test again/xyt If I use command: find . -type d |grep " " I will list 6 folders, but... (2 Replies)
Discussion started by: rdcwayx
2 Replies

7. Shell Programming and Scripting

Find all text files in folder and then copy to a new folder

Hi all, *I use Uwin and Cygwin emulator. I´m trying to search for all text files in the current folder (C/Files) and its sub folders using find -depth -name "*.txt" The above command worked for me, but now I would like to copy all found text files to a new folder (C/Files/Text) with ... (4 Replies)
Discussion started by: cgkmal
4 Replies

8. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies

9. Shell Programming and Scripting

find how many files are in use in a folder

How can i find how many files are in use in a folder or its sub folders in unix i tried with fuser .. but i coulnt getting ... (3 Replies)
Discussion started by: smongam
3 Replies

10. Shell Programming and Scripting

Take a folder name and find it in another folder (Complicated)

Hi Script Experts, Here is my scenario: 1. /var/mqm/qmgrs folder will contain 11 folders as follows: 1. /var/mqm/qmgrs/Folder_Name1 ....................../Folder_Name2 ....................../Folder_Name3 ....... ...................../Folder_Name11 2. if Folder_Name1 exists... (5 Replies)
Discussion started by: hkhan12
5 Replies
Login or Register to Ask a Question