Sponsored Content
Top Forums Shell Programming and Scripting Search through subfolders and move them into separate folder on the base of file size Post 302366728 by panyam on Friday 30th of October 2009 08:00:20 AM
Old 10-30-2009
Hi infiant,

Here is my clumsy code which serves the need.

Pls test it thoroughly before using it in production.

1. place the script in the path just before the search path . In your case in will be "/".

2. change the size parameters according to your requirement.

3. Assumed that you have created directories "HEALTHY","UNHEALTHY" and "OTHERS" in the proper path.

Code:
path="/disk1/jvsh/TEST/TES/FORUM"

## Replace the above bold one with the search path


pres=`pwd`

find $path  -name "abc.data"  -size +1c -print > healthy_files.lst

find $path  -name "abc.data" -size -3c > unhealthy.lst

find $path  ! -name  "abc.data" > others.lst

for file in `awk -F"/" '{$NF=" ";print }' OFS="/" healthy_files.lst | sort -u`
do
echo "$file"
mv  "$file" /disk1/jvsh/TEST/TES/HEALTHY ##put your healthy dirpath
done

for file in `awk -F"/" '{$NF=" ";print }' OFS="/" unhealthy.lst | sort -u`
do
echo "$file"
mv "$file" /disk1/jvsh/TEST/TES/UNHEALTHY 
##put your unhealthy dirpath in place of bold
done


for file in `awk -F"/" '{$NF=" ";print }' OFS="/" others.lst | sort -u `
do
echo "$file"
if [ "$file" = "$path""/" -o "$file" = "$pres""/" ];then
echo "nothing"
else
mv "$file" /disk1/jvsh/TEST/TES/OTHERS 2>/dev/null
fi
done

##put your others dirpath in place of bold

rm healthy_files.lst unhealthy.lst others.lst

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

send a mail whenever a file is updated in certain folder or its subfolders

send a mail to a group of users whenever a file is updated in certain folder or its subfolders on an unix server (3 Replies)
Discussion started by: ashishabhishek
3 Replies

2. Shell Programming and Scripting

Move the file from one folder to another folder

Hi, I have a requirement to move a file from one folder(a) to another folder(b) only when folder (b) have a write permission. Folder permission is 755 If the permission is otherthan 755 we need to come out of the loop I will appreciate your help Thanks Soll (1 Reply)
Discussion started by: sollins
1 Replies

3. 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

4. Shell Programming and Scripting

Search in folder and subfolders

How can this be done? I mean, I want to search for all *png *jpg *bmp files in my ~/Pictures/ folder....How can I list them? Thank you geeks :) :b: (2 Replies)
Discussion started by: hakermania
2 Replies

5. UNIX for Dummies Questions & Answers

Search current folder and subfolders with grep

Hello, Neither ‘Grep -r' nor ‘grep -R' is working in my environment. (Searching for a text pattern in the files) Any suggestions... Using SunOS 5.9 Thanks, Trinanjan. (1 Reply)
Discussion started by: bhanja_trinanja
1 Replies

6. Shell Programming and Scripting

want to move set of file from one folder to another folder

Hi all, let me explain my requirments i am having 5 folder with different name for eg) abc , cdf , efd, rtg, ead each 5 folders contain 15 files i want to move 10 files to some other folder, remain 5 files should be there in the same folder. give me some suggestion on this. (6 Replies)
Discussion started by: natraj005
6 Replies

7. Solaris

Move files to another folder base on DU

Hi, I want to move files like *.txt to another filesystem on the same server only when the disk usage reaches 80% or more. But need to keep the latest 5 files. After that delete from the original. How to proceed? Please help Gav... (5 Replies)
Discussion started by: Gavisht
5 Replies

8. Red Hat

Separate the apache user file and move or copy some were

Hi all, I'm Using Centos 6.4 /opt/my_aplication/entry/data/0/ There are Thousands of files in this Directory, Only i need to copy or move the apache User's file from this to /tmp/backup , I have listed apache user's file using find . -user apache -type f , its gave me the only apache... (2 Replies)
Discussion started by: babinlonston
2 Replies

9. Shell Programming and Scripting

Move specific folders and subfolders in a directory

I am trying to move specific folders and subfolders within a directory using the below. I can see the folders to move and they are at the location, but I am getting an error. Thank you :). mv -v /home/cmccabe/Desktop/NGS/API/6-10-2016{bam/{validation,coverage},bedtools /media/cmccabe/"My... (6 Replies)
Discussion started by: cmccabe
6 Replies

10. UNIX for Beginners Questions & Answers

UNIX utility to find difference in folder, file and contents of file against a base version

Hi, I am trying to find out whether there are any Unix utilities that compares folders, files and contents within the file and provides a comprehensive report. The comparison can be against base version of a folder and file with content. Can you please let me know of such a utility? Thanks,... (6 Replies)
Discussion started by: Sripathi_ks
6 Replies
tcpvmexportd(1) 					      General Commands Manual						   tcpvmexportd(1)

NAME
tcpvmexportd - transcode PVM3 export interface SYNOPSIS
tcpvmexportd -s|-m [ options ] COPYRIGHT
tcpvmexportd is Copyright (C) by Malanchini Marzio DESCRIPTION
tcpvmexportd This is the frontend for all the activity of export_pvm module: the program is spawned on all cluster hosts and wait to do the encode work. OPTIONS
-s Start tcpvmexportd in slave mode (internal use of export_pvm) [default]. Sub Options for slave mode -j Start merger process [off]. -L Create only the merge list [off]. -c name Name of slave function req in slave mode [none]. -x parameters Multiplex parameters [none]. -1 param First parameter to pass to the slave function [null]. -2 param Second parameter to pass to the slave function [null]. -3 param Third parameter to pass to the slave function [null]. -t type Elab video or audio frame (video|audio|system|multisystem) [video]. -f name Out file name [/tmp/my_file_name] -p number Multipass (0,1,2,3) [0]. -M Enable internal multipass [off]. -m Start tcpvmexportd in master mode [off]. Sub Options for master mode -j Start the batch merge mode [off]. -C Check the config or merge file [off]. -f name Input file name [/tmp/my_file_name] -h Print help. -v Print the version. EXAMPLES
Command: tcpvmexportd -m -j -f mylistfile.lst Run tcpvmexportd in batch merge mode. tcpvmexportd -m -C -f mylistfile.lst Check the config or the merge file. AUTHORS
tcpvmexportd was written by Marzio Malanchini <marzio_malanchini@vodafone.it> SEE ALSO
transcode(1) tcpvmexportd(1) 8th August 2003 tcpvmexportd(1)
All times are GMT -4. The time now is 03:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy