How to find a filename of a folder?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to find a filename of a folder?
# 1  
Old 03-18-2015
How to find a filename of a folder?

Hi,

Please help me i have a file directory in .txt. inside this directory is a list of names of folders to find inside in a folder.

to make more easy to understand

below is my list inside .txt:
foldernameA
foldernameB
foldernameC

I need to check if those folder names are inside foldernameD if exist then execute.
# 2  
Old 03-18-2015
Hello cmarzan,

Following may help you in same but not tested though.
Code:
cat folder.ksh
FIRST_PATH=foldernameD
while read line
do
 PATH=$FIRST_PATH/$line
 if [[ -d $PATH ]]
 then
  echo $line " present in path " $PATH
 else
  echo $line " NOT present in path " $PATh
 fi
done < "Input_file"

Thanks,
R. Singh
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find all pdf an get make a folder from filename substring

Hi , i need your advice. i will find all *.pdf files and make a folder for every different prefix of file names. for example: test_21424234.pdf new_242342.pdf at the and i will that i create ( if not exits ) a new folder "test" and "new" , afterwards i will move the file in this new... (3 Replies)
Discussion started by: Maxwill
3 Replies

2. Shell Programming and Scripting

Compare filename to file folder

Hi. I have a problem, could you help me ? Situation: there are alot of files in directory_1, with the names like "notneeded1blabla.bla", "notveryneededblabla.gla". there is directory_2 that has directories with names like that: "bla_needed1", "blab_veryneeded". What i need so much is to place... (7 Replies)
Discussion started by: sw_and
7 Replies

3. Shell Programming and Scripting

Bash script to sort files into folder according to a string in the filename

Hi all. I am very new to linux scripting and i have a task i can only solve with a script. I need to sort files base on the date string in their filenames and create a folder using the same date string then move the files to their respective folders. Scenario: Folder Path:... (1 Reply)
Discussion started by: ace47
1 Replies

4. Shell Programming and Scripting

URGENT!!! bash script to sort files into folder according to a string in the filename

Hi all. I am very new to linux scripting and i have a task i can only solve with a script. I need to sort files base on the date string in their filenames and create a folder using the same date string then move the files to their respective folders. Scenario: Folder Path:... (1 Reply)
Discussion started by: ace47
1 Replies

5. Shell Programming and Scripting

Checking files in folder using starting string for filename

Hi, How do i check if there are any files present in the folder with some specific starting string. For eg :- I have used this where Source_File is filename parameter. if then return 2 fi But in my case the source file name is not constant. The only constant thing is... (10 Replies)
Discussion started by: chetancrsp18
10 Replies

6. Shell Programming and Scripting

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

Hi all I'm new to your forum but not new to shells. I'm having a little trouble though as it's been quite some time since I scripted. Here's what I'm trying to do: I'm trying to search a directory named '/var/root/Applications' for another directory 'fooBar'. The "Applications" directory... (9 Replies)
Discussion started by: DC Slick
9 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. UNIX for Dummies Questions & Answers

Jar/Tar to a diffent folder/same folder w/ filename

Hi, I want to extract myfile.war to a folder which is in the same folder with war file.I did this as normal: jar -xvf myfile.war But it exploded all the content of file to the same level folder instead of that I was expecting to create a folder called myfile. This works with tar: ... (0 Replies)
Discussion started by: reis3k
0 Replies

9. UNIX for Dummies Questions & Answers

help to find find filename usingFile pointer in c

Hi .. I am having a file pointer .. it have declared some where tough to find out that ..Can we find out the filename associated with file pointer ... i mean is there any function FILEPOINTER.filename() is there in c ??... Thanks, Arun (2 Replies)
Discussion started by: arunkumar_mca
2 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