Copying

for testing script creating fromfolder with example problem files and tofolder

  • mkdir 000test && cd 000test && mkdir 1 2 && cd 1/ && touch "01 23" a.jpg b.jpg C.jpg d.jPg e.ogg f f.jpg g G.jPg && cd ..

best method from http://en.wikipedia.org/wiki/Touch_%28Unix%29#Examples

  • find . -exec touch {} \;

This method is relatively slow. The faster method will be:

  • find . | xargs touch

If the file names or subdirectory names contain spaces, the following should be used:

  • find . -print0 | xargs -0 touch

therefore last way is best only how then to make uperlower case include/exclude

also examples from http://en.wikipedia.org/wiki/Find#Execute_an_action shows the same info

To copy

  • If many empty subdirectories and some has files then copy all files exept folders to other folder
    cd /problemfolder/
    find . -type f -print0 | xargs -I{} -0 cp {} ~/ForexampleDesktop/solutionfolder
    or simpler
    find ProbleMFoldeRNamE -type f -exec cp {} solutionfolder/ \;
  • To find all specific type files and copy them without folders to one folder use (this has problem with uperLOWER filetypenames)
    find ~/FromPicturesFolderName -name "*.jpg" -exec cp \{\} ~/ToAll_Pictures/ \;
    or using commands in variables (this has problem with space names and uperLOWER filetypenames
    for file in $(find ProbleMFoldeRNamE -name *.jPg);do cp ${file} solutionfolder/; done
    • P.S. insted of copy to move use instead of cp use mv
    • P.S.2. and i hope this made some more idea of posibilities and that theese examples made u more understanding theese commands.

...


Kangarooo sidepages:


CategoryHomepage

Kangarooo/Copying (last edited 2012-10-13 20:29:36 by kangarooo)