12-29-2008
Need to create a script to show what files in what folders
Hi everyone,
I'm stuck with this scenario where our system creates files every night and puts them in several folders according from whom it came from.
I have managed to create a script which will list the folders in one column and the files that are in them in another column, now my problem is when some of these folders have multiple files created for the day I have a double entry in the folders column. Below is an example of what I mean.
Folder1 File1-1
Folder2 File2-1
Folder3 File3-1
Folder3 File3-2
Folder4 File4-1
This is how I would like it to show;
Folder1 File1-1
Folder2 File2-1
Folder3 File3-1, File3-2
Folder4 File4-1
How can I achieve this. Please guide me resolve this problem.
This is an example of my script,
#!/bin/sh
find /home/user/ -name testfile* | sort -k 4 | cut -c20-24 > folders
find /home/user/ -name testfile* | sort -k 4 | cut -c30-36 > files
paste folders files > final
cat final
Thank you all for your help.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi guys:
I've got this problem, I want to move a bunch of files to 3 different folders, without any specific order, and I'm trying to automatize it with a shell script.
I'm a newbie at shell scripting so this is my first try:
#!/bin/bash
COUNTER=`ls -1 | wc -l`
while
do
ARRAY=(... (11 Replies)
Discussion started by: wretchedmike
11 Replies
2. Shell Programming and Scripting
Hi
I want to write a small script that will create folders named from `AAAA' all the way to `ZZZZ'.
That is:
`AAAA'
`AAAB'
`AAAC'
...
`AABA'
`AABB'
`AABC'
...
`ABAA'
`ABAB'
`ABAC'
...
`ABBA'
...
`ZZZZ' (4 Replies)
Discussion started by: ksk
4 Replies
3. Shell Programming and Scripting
Hello this is the script Im working on
I have a picture collection that I rescued from a hard drive and there are thousands of pictures saved in one folder. What I need is to create several folders and put lets say around 200 pictures in each folder.
At the end instead of having one huge... (8 Replies)
Discussion started by: kizofilax
8 Replies
4. Shell Programming and Scripting
Hello!
I need to realize such task.
1. In my user's home dir I have folder1;
2. In folder1 I have some (various count) subfolders with random names;
3. In these subfolders I have one file anyname.pdf (various name in each subfolder) and file content.txt (constant name in each subfolder)
##... (7 Replies)
Discussion started by: optik77
7 Replies
5. UNIX for Dummies Questions & Answers
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. UNIX for Dummies Questions & Answers
hi again,
having an issue with the code here because it doesnt work :D
can someone point what and how to change, please.
#!/bin/bash
#create directory mylabs, inside create 6 directories named by user.
DIR1="$1"
DIR2="$2"
if ; then
echo -n " there is a folder named mylabs,
what... (1 Reply)
Discussion started by: me.
1 Replies
7. Shell Programming and Scripting
Hi All,
Could any one help me with a shell script which will create different sub folders in a folder and of which the sub folders names should be taken from a text file.
Thanks (1 Reply)
Discussion started by: chetansingh23
1 Replies
8. Shell Programming and Scripting
Hello all,
I would appreciate any help to write a script. I have folder A which contains over 30 thousands xml files, I would like create multiple folders and move those files (500 in each folders).
Thank you (1 Reply)
Discussion started by: mmsiddig
1 Replies
9. Shell Programming and Scripting
Hi Everyone,
I work for GE Money IVR as a DB analyst and the environment on which I work is Solaris 5.0 server and Oracle 11g.
I got a project in which I have to clean up the folders and files which are not used in DB.
I copied an existing script and edited it, dont know this is the... (5 Replies)
Discussion started by: habeeb506
5 Replies
10. Shell Programming and Scripting
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