View previous topic :: View next topic |
Author |
Message |
strubbldesign Guru
Joined: 16 Jan 2005 Posts: 354 Location: still somewhere in the matrix but once i was able to look out of it
|
Posted: Sun Feb 10, 2013 10:00 am Post subject: copy a table |
|
|
Hi.
I've managed to get all grafic files i need to write into a txt-file.
Code: | find -size +95k | egrep "(.gif|.jpg|.png|.swf|.JPG|.PNG)" >> /home/fysi/Desktop/to_copy.txt |
now i neet an easy way to copy all the files with the path as written in the file o a different location
the file strukture is:
Quote: | ./Downloads/Folder.jpg
./Downloads/Photo120916_001.jpg
./Downloads/ring.gif
./Downloads/tas tebery.jpg
./Eigene Bilder/Berg und Wolken.jpg
./Eigene Bilder/Eisberg.jpg
./Eigene Bilder/Hütte.jpg
|
thanks for your help...
PS there are more then 4000 Lines! _________________ Always look on the bright side of live. badu badubadubado |
|
Back to top |
|
|
strubbldesign Guru
Joined: 16 Jan 2005 Posts: 354 Location: still somewhere in the matrix but once i was able to look out of it
|
Posted: Sun Feb 10, 2013 12:16 pm Post subject: |
|
|
coud you give me an example to make a script that takes a pre-deffinied String, such as "cp -rv" and puts it in front of each line of the to_copy.txt. and a nother string, "/media/Photo_Backup" to the end of each line
thanks _________________ Always look on the bright side of live. badu badubadubado |
|
Back to top |
|
|
ronsu n00b
Joined: 10 Feb 2013 Posts: 2
|
Posted: Sun Feb 10, 2013 2:02 pm Post subject: |
|
|
Do you need the .txt file? If i understood what you wanted this could just do it:
Code: |
find /path/to/your/images -regextype posix-egrep -iregex ".*\.(gif|png|jpg)$" -size +95k -exec cp --parents {} /path/to/your/backupdirectory/ \;
|
You can add the echo to exec if you need the .txt file for some reason.
Other idea could be to make a tar package with find and use the tar package as backup. |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21642
|
Posted: Sun Feb 10, 2013 4:29 pm Post subject: |
|
|
ronsu wrote: | Do you need the .txt file? If i understood what you wanted this could just do it:
Code: |
find /path/to/your/images -regextype posix-egrep -iregex ".*\.(gif|png|jpg)$" -size +95k -exec cp --parents {} /path/to/your/backupdirectory/ \;
|
You can add the echo to exec if you need the .txt file for some reason.
Other idea could be to make a tar package with find and use the tar package as backup. | The text file is unnecessary, but since he generated it, he can perform the copy much more efficiently than the command you specified.
OP: the use of spaces in your filenames complicates the situation. You need to quote the names properly, which could be difficult if you have embedded quotes. The safest solution would be a modification of the command proposed by ronsu: cd /path/to/your/images && (find . -regextype posix-egrep -iregex ".*\.(gif|png|jpg|swf)$" -size +95k -print0 | tar --null -T - -c -f - | tar -C /path/to/destination -x -f - ). You can break this into a find with a later tar if you prefer, but take care to use null terminators.
Also, you did not indicate whether the receiving directory has the required structure. I assume you want to keep the structure, but the request you posted would discard the structure. The use of the double tar will preserve directory structure. |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sun Feb 17, 2013 2:22 pm Post subject: |
|
|
strubbldesign, ronsu, hu, et al ...
Alternately, rsync will also maintain the directory structure, and handle any special chars (spaces, etc) in the filenames:
Code: | % find . -regextype posix-egrep -iregex ".*\.(gif|png|jpg|swf)$" -size +95k -print0 | rsync -av --files-from=- --from0 ./ /path/to/destination |
best ... khay |
|
Back to top |
|
|
|