treecopy.awk 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #
  2. # Copyright (C) 2005, 2006 Stephen Jungels
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful, but
  10. # WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # General Public License for more details.
  13. #
  14. # See COPYING for the full text of the license.
  15. function deregex(str)
  16. {
  17. gsub ("\\(", "\\(", str);
  18. gsub ("\\)", "\\)", str);
  19. gsub ("\\[", "\\[", str);
  20. gsub ("\\]", "\\]", str);
  21. gsub ("\\.", "\\.", str);
  22. gsub ("\\?", "\\?", str);
  23. gsub ("\\*", "\\*", str);
  24. gsub ("\\|", "\\|", str);
  25. gsub ("\\+", "\\+", str);
  26. return str;
  27. }
  28. {
  29. if (index ($0, "http://") != 1)
  30. {
  31. path = $0;
  32. d2 = deregex(d);
  33. sub (d2, "", path);
  34. n = split (path, subdirs, "/");
  35. base = subdirs[n];
  36. b2=deregex(base);
  37. sub (b2, "", path);
  38. print "mkdir -p \"" to path "\"";
  39. print "rsync -t \"" $0 "\" \"" to path "\"";
  40. }
  41. }