Is it possible to only copy selected files+its directories when you are copying recursively?
From the above line, I want to only copy *txt and *ini files from /OriginalFolder/*
Regards
Last edited by vbe; 12-31-2017 at 07:24 AM..
Reason: code tags please even for so lttle...
I tried the following command, which didn't work:
So I am trying to see which folders were modified 1 or 2 days ago and only copy over the files *.ini and *.txt (including the folder which contains them).
Last edited by Scrutinizer; 01-06-2018 at 06:04 PM..
Reason: code tags
The find primary -mtime 1 looks for file that were modified exactly 24 hours ago to the finest resolution of timestamps available on the filesystem you're traversing. If you want to look for files that were modified sometime up to 48 hours ago, you would do that with:
And, if you need to group primaries together in an expression, you need to surround them with escaped parentheses such as: not with braces such as:
and there can never be any space between the backslash character and the escaped parenthesis following it.
Maybe you want something more like:
to get a list of absolute pathnames of the files you want to copy as long as the files you want to copy only appear in leaf directories. You'll have to do some post-processing of the output to recreate the directory hierarchy using something like cpio, pax, or tar to keep the original ownership and modes.
But, of course, this assumes that your list of directories updated in the last two days is not large enough to cause a command-line too long error as it constructs the outermost find command.
And, as RudiC noted, if a file in a directory is updated without creating a new file or deleting an old file, the directory timestamp won't be updated.
None of this has been tested, but hopefully it will give you a way to start moving forward. Note that if directories other than those that are leaves on the tree are updated, some of the files in the list produced might not actually be in a directory whose leaf directory changed in the last two days AND if non-leaf directories are updated some files may appear in the output list more than one time so you may need to weed out duplicates.
I need to copy a complete directory structure into a new location. But I want to have all files copied into one directory and leave out the directory structure. So all files must be placed in one directory. (4 Replies)
Hi.
I found many scripts in the web of achieving this.
But I like to use this one
find /EDWH-DMT03 -xdev -size +10000 -exec ls -la {} \;|sort -n -k 5 > LARGE.rst
But the problem is, why it still list out files with 89 bytes as the output? Is there anything wrong with the command?
My... (7 Replies)
I love the -newerct flag for the Cygwin find command on windows.
Can I use "/usr/bin/find . -newerct '3 hours ago'" to conditionally copy a directory tree so that only the files in the directory tree that are younger than 3 hours are copied to my destination directory such that the directory... (4 Replies)
Hello!
I know what i s recursion, but can't imagine what shoudl be "recursicve copying" of files?
Please, what should mean:
cp -r /home/hope/files/* /home/hope/backup
Can someone helpme with a simple example?
Many thanks!!! (6 Replies)
Hi
I need to copy a huge directory with thousands of files onto another directory but without *.WMV files (and without *.wmv - perhaps we need to use *.).
Pls advise how can I do that.
Thanks (17 Replies)
I would like to transfer all files ending with .log from /tmp and to /tmp/archive (using find )
The directory structure looks like :-
/tmp
a.log
b.log
c.log
/abcd
d.log
e.log
When I tried the following command , it movies all the log files... (8 Replies)
Hi all:
Here's my dilemma: to identify files of a specific type, copy them to a new location while preserving the original file attributes (date, time, full path, etc), and at the same time capture the count of the number of files identified as a variable for later reporting.
Here's where I... (9 Replies)
Hi,
find . | xargs -s 47518 can list all the files and directories recursively , is there any possibility to copy only files from directories and subdirectoreis once it is listed. Please help
Thans & Regards
Uma (3 Replies)
Hi
I am a shell-script newbie and am looking to synchronize certain files in two directory structures.
Both these directory-trees are in CVS and so I dont want the CVS directory to be copied over.
I want only .sh and .pl files in each subdirectory under these directory trees to be... (3 Replies)