02-21-2009
Finally I made this:
<
for SUBFOLDER in `(find $SOURCE -type f -mtime -10 | awk 'BEGIN { FS = "/" } ; { print $7 }')`;
do
mkdir -p $DEST/$SUBFOLDER;
done
for SUBFOLDER in `(find $SOURCE -type f -mtime -10 | awk 'BEGIN { FS = "/" } ; { print $7 }')`;
do
mv $SOURCE/$SUBFOLDER $DEST/$SUBFOLDER;
done
>
And this works for my $SOURCE path. Changing this path requires to adjust the awk column prints accordingly.
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I need to move a bunch of files into folders that have the same name. I wanted to either do this with some filter command or some type of batch file that I could save that would already include all of the mv commands since I will have to do this process often. Whatever method you think is easier.
... (7 Replies)
Discussion started by: italia5
7 Replies
2. 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
3. Shell Programming and Scripting
Hi Friends,
Below is my requirement and i am not clear how to approach this issue in unix programming.
I have a folder with 2500 files. The files are in below format.
1234_name1.txt
1234_name123.txt
4567_name1.txt
4567_name123.txt
and i need a program which will read each file from this... (5 Replies)
Discussion started by: diva_thilak
5 Replies
4. Shell Programming and Scripting
Hello,
I need a simple script to Auto-detect new files and folders in the directory.
And then I need to zip the new files and bzip2 new folders and move them out of that folder where I am detecting changes to the other folder.
Remember, I need simple one. If anyone could do it fast, I may... (1 Reply)
Discussion started by: juzt1s
1 Replies
5. Shell Programming and Scripting
Hi,
I have a sub directory with a number of files and folders. What i want is a subdirectory with just folders and not files for cleanliness sake. So I want to move the files into the new folder but keep the folders in the same place. Move all files (but not folders) to new folder.
I am... (4 Replies)
Discussion started by: Hopper_no1
4 Replies
6. Shell Programming and Scripting
Hi Unix Gurus,
I am able to copy only files that exist in the parent folder. My parent folder has sub folders and within sub folders there are lots files.
I need to copy folder, sub folders and files from Unix to the remote windows SFTP location.
The directory structure is something like... (1 Reply)
Discussion started by: shankar1dada
1 Replies
7. Solaris
Hi All,
I want to move the files in to different folders based on the files month in the file timestamp.
For example
All the september files in the directory should moves into the folder "sep_bkp_files" , August files in to aug_bkp_files folder...
Please help me to achive the above... (10 Replies)
Discussion started by: velava
10 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
How do I move all folders and its contents from a directory A to another directory B, skipping all files in Directory A ?
---------- Post updated at 12:53 PM ---------- Previous update was at 12:42 PM ----------
Ok. Got it.
mv /A/*/ /B/ (1 Reply)
Discussion started by: DHeisenberg
1 Replies
CP(1) FSF CP(1)
NAME
cp - copy files and directories
SYNOPSIS
cp [OPTION]... SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... --target-directory=DIRECTORY SOURCE...
DESCRIPTION
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
Mandatory arguments to long options are mandatory for short options too.
-a, --archive
same as -dpR
--backup[=CONTROL]
make a backup of each existing destination file
-b like --backup but does not accept an argument
--copy-contents
copy contents of special files when recursive
-d same as --no-dereference --preserve=link
--no-dereference
never follow symbolic links
-f, --force
if an existing destination file cannot be opened, remove it and try again
-i, --interactive
prompt before overwrite
-H follow command-line symbolic links
-l, --link
link files instead of copying
-L, --dereference
always follow symbolic links
-p same as --preserve=mode,ownership,timestamps
--preserve[=ATTR_LIST]
preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: links, all
--no-preserve=ATTR_LIST
don't preserve the specified attributes
--parents
append source path to DIRECTORY
-P same as `--no-dereference'
-R, -r, --recursive
copy directories recursively
--remove-destination
remove each existing destination file before attempting to open it (contrast with --force)
--reply={yes,no,query}
specify how to handle the prompt about an existing destination file
--sparse=WHEN
control creation of sparse files
--strip-trailing-slashes remove any trailing slashes from each SOURCE
argument
-s, --symbolic-link
make symbolic links instead of copying
-S, --suffix=SUFFIX
override the usual backup suffix
--target-directory=DIRECTORY
move all SOURCE arguments into DIRECTORY
-u, --update
copy only when the SOURCE file is newer than the destination file or when the destination file is missing
-v, --verbose
explain what is being done
-x, --one-file-system
stay on this file system
--help display this help and exit
--version
output version information and exit
By default, sparse SOURCE files are detected by a crude heuristic and the corresponding DEST file is made sparse as well. That is the
behavior selected by --sparse=auto. Specify --sparse=always to create a sparse DEST file whenever the SOURCE file contains a long enough
sequence of zero bytes. Use --sparse=never to inhibit creation of sparse files.
The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup
option or through the VERSION_CONTROL environment variable. Here are the values:
none, off
never make backups (even if --backup is given)
numbered, t
make numbered backups
existing, nil
numbered if numbered backups exist, simple otherwise
simple, never
always make simple backups
As a special case, cp makes a backup of SOURCE when the force and backup options are given and SOURCE and DEST are the same name for an
existing, regular file.
AUTHOR
Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.
REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU-
LAR PURPOSE.
SEE ALSO
The full documentation for cp is maintained as a Texinfo manual. If the info and cp programs are properly installed at your site, the com-
mand
info cp
should give you access to the complete manual.
cp (coreutils) 4.5.3 February 2003 CP(1)