GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Question : SSH / Copy / Same Path...HELP ! ! ! (https://gfy.com/showthread.php?t=991944)

Inter-Sex 10-11-2010 10:45 AM

Question : SSH / Copy / Same Path...HELP ! ! !
 
Hello

I need some help, so if you have time...don't stop reading.

SSH is not my strongest point. I have for example 20 times the dir "clips" at my server, (under different domains)
and would like to do a search just in those dirs "clips", to "*.ext"
(the "clips" directory has other dirs in it : path /clips/clip33/clips33-a/*)

After that i would like to copy all found files to a new directory, but if it is posible i would like to get
the same structure in the new directory. So in the new dir would look like this "NEW-Dir/clips/clip33/clips33-a/*"

Which commands i have to use for all this ?

If somebody can help me with a ssh string, that would be great and saves me a lot of work manually.

Thank you in advance.

~ Renaldo,

fris 10-11-2010 11:15 AM

Quote:

Originally Posted by Inter-Sex (Post 17596420)
Hello

I need some help, so if you have time...don't stop reading.

SSH is not my strongest point. I have for example 20 times the dir "clips" at my server, (under different domains)
and would like to do a search just in those dirs "clips", to "*.ext"
(the "clips" directory has other dirs in it : path /clips/clip33/clips33-a/*)

After that i would like to copy all found files to a new directory, but if it is posible i would like to get
the same structure in the new directory. So in the new dir would look like this "NEW-Dir/clips/clip33/clips33-a/*"

Which commands i have to use for all this ?

If somebody can help me with a ssh string, that would be great and saves me a lot of work manually.

Thank you in advance.

~ Renaldo,

This will take care of name collision, so if you have the same files in multiple directories.

find to get a list of all the files (just change the extension from .jpg to whatever
awk to create a copy command with the original filename and the modified filename
bash to pass it to the shell to be executed

Code:

find . -name "*.jpg" | awk '{ str=$0; sub(/\.\//, "", str); gsub(/\//, "-", str); print "cp " $0 " new/" str }' | bash

fris 10-11-2010 04:23 PM

hope this worked for you


All times are GMT -7. The time now is 07:24 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc