Sponsored Content
Top Forums Shell Programming and Scripting Find files of type within folder copy multiple results to different folders Post 302491615 by rdcwayx on Thursday 27th of January 2011 10:22:39 PM
Old 01-27-2011
Code:
function makeBackup ()
{
    loc="$1"
    [ $# -ne 1 ] && echo "Please enter one location to backup" && return 1
    [ -d "$loc" ] || echo "Location must be a directory" || return 2
    mkdir -p $loc/Debs $loc/TextFiles $loc/Rar

    find $loc -type f \( -name "*.deb" -o -name "*.txt" -o -name "*.rar" \) |while read file
    do
         case ${file##*.} in
             'deb') subfolder="Debs" ;;
             'txt') subfolder="TextFiles" ;;
             'rar') subfolder="Rar" ;;
         esac
         cp $file $loc/$subfolder
    done
}


Last edited by rdcwayx; 01-27-2011 at 11:32 PM..
This User Gave Thanks to rdcwayx For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find and replace files in multiple folders

Hi there, I would like to write a script to automate the copy and renaming of files in multiple dir. I have a generic file named s253e.prb and would like to copy this to multiple dir and rename it. Example: Dir is AL-M1 and the prb file name is AL-M1.prb. I would like to be able to... (6 Replies)
Discussion started by: lodey
6 Replies

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

3. Shell Programming and Scripting

copy some files from users home folders to my folder

i have users home directories in /home all the users have some files starting with character e and i want to copy all these files in a folder in my (root) home using a script i tried the script for i in m5 do cd m5 cp e1* /home/pc/exam cd .. done but get these... (3 Replies)
Discussion started by: pcrana
3 Replies

4. UNIX for Dummies Questions & Answers

Copy multiple files with space to folder

Please help , I am in an urgent need, Please help nawk '{for(i=1;i<=NF;i++){printf("%s\n",$i)}}' filename | sed 's/.*com//' | nawk '/pdf/ {printf("F:%s\n",$0)}' | while read line; do mv $line /images/; done the above script works for without spaces but,My path is also having some space... (3 Replies)
Discussion started by: umapearl
3 Replies

5. Shell Programming and Scripting

HELP! Need to compare 2 folders on 2 different systems, and copy unmatched filenames to other folder

This has been tearing my hair out. I need to: 1: compare server1:/data/archive/ to server2:/data/archive/ (through rsync, ssh, etc) 2: filenames that don't match, get copied (scp) to server2:/data/ server1 and server2 have ssh, scp, rsync access between eachother. Is there any option in... (3 Replies)
Discussion started by: damang111
3 Replies

6. UNIX for Dummies Questions & Answers

Unzipping a file which has multiple folders and each folder has the files with same name in it

Hi, I have a zipped file a.zip. This has got multiple folders in it say x and y. x contains a.txt and y contains a.txt. Is it possible to unzip this file and have the 2 files extracted and rename them to unique names. Thanks in advance. (1 Reply)
Discussion started by: arunkesi
1 Replies

7. Shell Programming and Scripting

Search for specific file type in subdirectory with multiple folders

I have a directory that is in the below order (the --- is not part of the directory tree, only there to help illustrate: DATE --- main level Folder1 --- level under DATE plugin_out --- level under Folder1 variantCaller_out.40 --- level under plugin_out 001,002,003 --- level under... (3 Replies)
Discussion started by: cmccabe
3 Replies

8. Shell Programming and Scripting

How do you compare two folders and copy the difference to a third folder in a remote server?

How do you compare one local folder and a remote folder and copy the difference to a third folder in a remote folder.e.g. Folder A -- Is in a remote server and it has the following files TEST1.OUT TEST2.OUT TEST3.OUT Folder B --Is in a local server and it has the following files ... (5 Replies)
Discussion started by: cumeh1624
5 Replies

9. Shell Programming and Scripting

Execute multiple files in multiple folders and also output on same folder

How to execute multiple files in multiple folders and also output to be generated in the same folder? Hello Team, I have a path like Sanity_test/*/* and it has around 100+ folders inside with files. I would like to run/execute those files and output of execution to be placed on same /... (1 Reply)
Discussion started by: pushpabuzz
1 Replies

10. Shell Programming and Scripting

Copy local files to single remote host but multiple folders using rsync

I'm trying to copy a file myfile.scr from my local Linux server to multiple folders on remote AiX server using single rsync command. Below command helps me copy the file "myfile.scr" from my localhost to a remote host folder "/app/deployment/tmpfiles" rsync --delay-updates -F --compress... (1 Reply)
Discussion started by: mohtashims
1 Replies
ISALNUM_L(3)						   BSD Library Functions Manual 					      ISALNUM_L(3)

NAME
isalnum_l, isalpha_l, isblank_l, iscntrl_l, isdigit_l, isgraph_l, ishexnumber_l, isideogram_l, islower_l, isnumber_l, isphonogram_l, isprint_l, ispunct_l, isrune_l, isspace_l, isspecial_l, isupper_l, isxdigit_l -- character classification utilities LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <wctype.h> #include <xlocale.h> int isalnum_l(int c, locale_t loc); int isalpha_l(int c, locale_t loc); int isblank_l(int c, locale_t loc); int iscntrl_l(int c, locale_t loc); int isdigit_l(int c, locale_t loc); int isgraph_l(int c, locale_t loc); int ishexnumber_l(int c, locale_t loc); int isideogram_l(int c, locale_t loc); int islower_l(int c, locale_t loc); int isnumber_l(int c, locale_t loc); int isphonogram_l(int c, locale_t loc); int isprint_l(int c, locale_t loc); int ispunct_l(int c, locale_t loc); int isrune_l(int c, locale_t loc); int isspace_l(int c, locale_t loc); int isspecial_l(int c, locale_t loc); int isupper_l(int c, locale_t loc); int isxdigit_l(int c, locale_t loc); DESCRIPTION
These functions are extended locale versions of the corresponding functions, with the _l removed. Also, see xlocale(3) for more information about extended locales. SEE ALSO
isalnum(3), isalpha(3), isblank(3), iscntrl(3), isdigit(3), isgraph(3), ishexnumber(3), isideogram(3), islower(3), isnumber(3), isphonogram(3), isprint(3), ispunct(3), isrune(3), isspace(3), isspecial(3), isupper(3), isxdigit(3), xlocale(3) BSD
March 11, 2005 BSD
All times are GMT -4. The time now is 10:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy