How to execute ln on find results

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












I want to make symlinks for image files in a directory in the server. Currently I'm doing it by executing this command using php function exec():



ln -sf path/to/source path/to/symlink


Both file names are the same.



And it's working greatly. In the next step I want to make symlinks for other sizes of that particular image which are stored alongside the original image.
I searched and find this link: Execute a command on find results which explains to use this format:



find ... -execdir rm ;


Now the furthest I got is to list files (full path) using find with the proper regex. But I have no idea how to use this output and link each file to the exact name in target directory.



P.S.: I only have access to the original image and its path.



EDIT:



As I mentioned I only have access to the image path and its filename. And I don't know how many sizes of the image is available. So I want to combine find and ln so that all image sizes of the original image file get linked to source files.
For example: I get the path to an original image like this:



path/to/file/microlancer.png


until now I was executing this command:



ln -sf path/to/file/microlancer.png path/to/symlink/microlancer.png


with an execution of a find I obtain these files:



path/to/file/microlancer-260x185.png
path/to/file/microlancer-120x120.png
path/to/file/microlancer-705x321.png
path/to/file/microlancer-450x223.png
path/to/file/microlancer-150x150.png
path/to/file/microlancer-495x350.png
path/to/file/microlancer-300x149.png
path/to/file/microlancer-705x350.png
path/to/file/microlancer-450x350.png
path/to/file/microlancer-180x180.png
path/to/file/microlancer-36x36.png


And I need a symlink in path/to/symlink/ for each above file.



php is not a matter here. I just need the command in linux. I only mentioned php to clarify that I don't have access to all files.










share|improve this question



















  • 4




    It's a little unclear what you're wanting to achieve. Would it be possible to post more detail, including, perhaps, the relevant part of your existing php exec() script ?
    – steve
    Sep 8 at 10:16






  • 1




    Also, what is the plan for the symlink path? For each found file, how would you determine what the associated symlink is? Please edit your question to include this information.
    – Sparhawk
    Sep 8 at 10:52







  • 1




    @steve There is a danger in it, his question may be closed as offtopic as a programming question :-(
    – peterh
    Sep 8 at 10:52










  • Would you like to create symbolic link for all the lines in the list that you had provided, instead of applying your command ln -sf path/to/file/microlancer.png path/to/symlink/microlancer.png on the images one by one?
    – Goro
    Sep 8 at 11:51















up vote
-1
down vote

favorite












I want to make symlinks for image files in a directory in the server. Currently I'm doing it by executing this command using php function exec():



ln -sf path/to/source path/to/symlink


Both file names are the same.



And it's working greatly. In the next step I want to make symlinks for other sizes of that particular image which are stored alongside the original image.
I searched and find this link: Execute a command on find results which explains to use this format:



find ... -execdir rm ;


Now the furthest I got is to list files (full path) using find with the proper regex. But I have no idea how to use this output and link each file to the exact name in target directory.



P.S.: I only have access to the original image and its path.



EDIT:



As I mentioned I only have access to the image path and its filename. And I don't know how many sizes of the image is available. So I want to combine find and ln so that all image sizes of the original image file get linked to source files.
For example: I get the path to an original image like this:



path/to/file/microlancer.png


until now I was executing this command:



ln -sf path/to/file/microlancer.png path/to/symlink/microlancer.png


with an execution of a find I obtain these files:



path/to/file/microlancer-260x185.png
path/to/file/microlancer-120x120.png
path/to/file/microlancer-705x321.png
path/to/file/microlancer-450x223.png
path/to/file/microlancer-150x150.png
path/to/file/microlancer-495x350.png
path/to/file/microlancer-300x149.png
path/to/file/microlancer-705x350.png
path/to/file/microlancer-450x350.png
path/to/file/microlancer-180x180.png
path/to/file/microlancer-36x36.png


And I need a symlink in path/to/symlink/ for each above file.



php is not a matter here. I just need the command in linux. I only mentioned php to clarify that I don't have access to all files.










share|improve this question



















  • 4




    It's a little unclear what you're wanting to achieve. Would it be possible to post more detail, including, perhaps, the relevant part of your existing php exec() script ?
    – steve
    Sep 8 at 10:16






  • 1




    Also, what is the plan for the symlink path? For each found file, how would you determine what the associated symlink is? Please edit your question to include this information.
    – Sparhawk
    Sep 8 at 10:52







  • 1




    @steve There is a danger in it, his question may be closed as offtopic as a programming question :-(
    – peterh
    Sep 8 at 10:52










  • Would you like to create symbolic link for all the lines in the list that you had provided, instead of applying your command ln -sf path/to/file/microlancer.png path/to/symlink/microlancer.png on the images one by one?
    – Goro
    Sep 8 at 11:51













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I want to make symlinks for image files in a directory in the server. Currently I'm doing it by executing this command using php function exec():



ln -sf path/to/source path/to/symlink


Both file names are the same.



And it's working greatly. In the next step I want to make symlinks for other sizes of that particular image which are stored alongside the original image.
I searched and find this link: Execute a command on find results which explains to use this format:



find ... -execdir rm ;


Now the furthest I got is to list files (full path) using find with the proper regex. But I have no idea how to use this output and link each file to the exact name in target directory.



P.S.: I only have access to the original image and its path.



EDIT:



As I mentioned I only have access to the image path and its filename. And I don't know how many sizes of the image is available. So I want to combine find and ln so that all image sizes of the original image file get linked to source files.
For example: I get the path to an original image like this:



path/to/file/microlancer.png


until now I was executing this command:



ln -sf path/to/file/microlancer.png path/to/symlink/microlancer.png


with an execution of a find I obtain these files:



path/to/file/microlancer-260x185.png
path/to/file/microlancer-120x120.png
path/to/file/microlancer-705x321.png
path/to/file/microlancer-450x223.png
path/to/file/microlancer-150x150.png
path/to/file/microlancer-495x350.png
path/to/file/microlancer-300x149.png
path/to/file/microlancer-705x350.png
path/to/file/microlancer-450x350.png
path/to/file/microlancer-180x180.png
path/to/file/microlancer-36x36.png


And I need a symlink in path/to/symlink/ for each above file.



php is not a matter here. I just need the command in linux. I only mentioned php to clarify that I don't have access to all files.










share|improve this question















I want to make symlinks for image files in a directory in the server. Currently I'm doing it by executing this command using php function exec():



ln -sf path/to/source path/to/symlink


Both file names are the same.



And it's working greatly. In the next step I want to make symlinks for other sizes of that particular image which are stored alongside the original image.
I searched and find this link: Execute a command on find results which explains to use this format:



find ... -execdir rm ;


Now the furthest I got is to list files (full path) using find with the proper regex. But I have no idea how to use this output and link each file to the exact name in target directory.



P.S.: I only have access to the original image and its path.



EDIT:



As I mentioned I only have access to the image path and its filename. And I don't know how many sizes of the image is available. So I want to combine find and ln so that all image sizes of the original image file get linked to source files.
For example: I get the path to an original image like this:



path/to/file/microlancer.png


until now I was executing this command:



ln -sf path/to/file/microlancer.png path/to/symlink/microlancer.png


with an execution of a find I obtain these files:



path/to/file/microlancer-260x185.png
path/to/file/microlancer-120x120.png
path/to/file/microlancer-705x321.png
path/to/file/microlancer-450x223.png
path/to/file/microlancer-150x150.png
path/to/file/microlancer-495x350.png
path/to/file/microlancer-300x149.png
path/to/file/microlancer-705x350.png
path/to/file/microlancer-450x350.png
path/to/file/microlancer-180x180.png
path/to/file/microlancer-36x36.png


And I need a symlink in path/to/symlink/ for each above file.



php is not a matter here. I just need the command in linux. I only mentioned php to clarify that I don't have access to all files.







find symlink php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 8 at 11:40

























asked Sep 8 at 10:06









Ali Sh

12




12







  • 4




    It's a little unclear what you're wanting to achieve. Would it be possible to post more detail, including, perhaps, the relevant part of your existing php exec() script ?
    – steve
    Sep 8 at 10:16






  • 1




    Also, what is the plan for the symlink path? For each found file, how would you determine what the associated symlink is? Please edit your question to include this information.
    – Sparhawk
    Sep 8 at 10:52







  • 1




    @steve There is a danger in it, his question may be closed as offtopic as a programming question :-(
    – peterh
    Sep 8 at 10:52










  • Would you like to create symbolic link for all the lines in the list that you had provided, instead of applying your command ln -sf path/to/file/microlancer.png path/to/symlink/microlancer.png on the images one by one?
    – Goro
    Sep 8 at 11:51













  • 4




    It's a little unclear what you're wanting to achieve. Would it be possible to post more detail, including, perhaps, the relevant part of your existing php exec() script ?
    – steve
    Sep 8 at 10:16






  • 1




    Also, what is the plan for the symlink path? For each found file, how would you determine what the associated symlink is? Please edit your question to include this information.
    – Sparhawk
    Sep 8 at 10:52







  • 1




    @steve There is a danger in it, his question may be closed as offtopic as a programming question :-(
    – peterh
    Sep 8 at 10:52










  • Would you like to create symbolic link for all the lines in the list that you had provided, instead of applying your command ln -sf path/to/file/microlancer.png path/to/symlink/microlancer.png on the images one by one?
    – Goro
    Sep 8 at 11:51








4




4




It's a little unclear what you're wanting to achieve. Would it be possible to post more detail, including, perhaps, the relevant part of your existing php exec() script ?
– steve
Sep 8 at 10:16




It's a little unclear what you're wanting to achieve. Would it be possible to post more detail, including, perhaps, the relevant part of your existing php exec() script ?
– steve
Sep 8 at 10:16




1




1




Also, what is the plan for the symlink path? For each found file, how would you determine what the associated symlink is? Please edit your question to include this information.
– Sparhawk
Sep 8 at 10:52





Also, what is the plan for the symlink path? For each found file, how would you determine what the associated symlink is? Please edit your question to include this information.
– Sparhawk
Sep 8 at 10:52





1




1




@steve There is a danger in it, his question may be closed as offtopic as a programming question :-(
– peterh
Sep 8 at 10:52




@steve There is a danger in it, his question may be closed as offtopic as a programming question :-(
– peterh
Sep 8 at 10:52












Would you like to create symbolic link for all the lines in the list that you had provided, instead of applying your command ln -sf path/to/file/microlancer.png path/to/symlink/microlancer.png on the images one by one?
– Goro
Sep 8 at 11:51





Would you like to create symbolic link for all the lines in the list that you had provided, instead of applying your command ln -sf path/to/file/microlancer.png path/to/symlink/microlancer.png on the images one by one?
– Goro
Sep 8 at 11:51











1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










find /path/to/file -name '*.png' -exec ln -s '' /path/to/symlink ';'





share|improve this answer






















  • Did you ever test this? Using backticks ` won't work.
    – Thomas
    Sep 8 at 14:21











  • thanks. that worked perfectly
    – Ali Sh
    Sep 9 at 4:57










  • thanks for correcting. I have used my iPhone two days ago. Of cource not backsticks! :-)
    – Afsin Toparlak
    Sep 10 at 18:15










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f467693%2fhow-to-execute-ln-on-find-results%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










find /path/to/file -name '*.png' -exec ln -s '' /path/to/symlink ';'





share|improve this answer






















  • Did you ever test this? Using backticks ` won't work.
    – Thomas
    Sep 8 at 14:21











  • thanks. that worked perfectly
    – Ali Sh
    Sep 9 at 4:57










  • thanks for correcting. I have used my iPhone two days ago. Of cource not backsticks! :-)
    – Afsin Toparlak
    Sep 10 at 18:15














up vote
0
down vote



accepted










find /path/to/file -name '*.png' -exec ln -s '' /path/to/symlink ';'





share|improve this answer






















  • Did you ever test this? Using backticks ` won't work.
    – Thomas
    Sep 8 at 14:21











  • thanks. that worked perfectly
    – Ali Sh
    Sep 9 at 4:57










  • thanks for correcting. I have used my iPhone two days ago. Of cource not backsticks! :-)
    – Afsin Toparlak
    Sep 10 at 18:15












up vote
0
down vote



accepted







up vote
0
down vote



accepted






find /path/to/file -name '*.png' -exec ln -s '' /path/to/symlink ';'





share|improve this answer














find /path/to/file -name '*.png' -exec ln -s '' /path/to/symlink ';'






share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 8 at 15:04









roaima

40.6k547110




40.6k547110










answered Sep 8 at 12:48









Afsin Toparlak

38114




38114











  • Did you ever test this? Using backticks ` won't work.
    – Thomas
    Sep 8 at 14:21











  • thanks. that worked perfectly
    – Ali Sh
    Sep 9 at 4:57










  • thanks for correcting. I have used my iPhone two days ago. Of cource not backsticks! :-)
    – Afsin Toparlak
    Sep 10 at 18:15
















  • Did you ever test this? Using backticks ` won't work.
    – Thomas
    Sep 8 at 14:21











  • thanks. that worked perfectly
    – Ali Sh
    Sep 9 at 4:57










  • thanks for correcting. I have used my iPhone two days ago. Of cource not backsticks! :-)
    – Afsin Toparlak
    Sep 10 at 18:15















Did you ever test this? Using backticks ` won't work.
– Thomas
Sep 8 at 14:21





Did you ever test this? Using backticks ` won't work.
– Thomas
Sep 8 at 14:21













thanks. that worked perfectly
– Ali Sh
Sep 9 at 4:57




thanks. that worked perfectly
– Ali Sh
Sep 9 at 4:57












thanks for correcting. I have used my iPhone two days ago. Of cource not backsticks! :-)
– Afsin Toparlak
Sep 10 at 18:15




thanks for correcting. I have used my iPhone two days ago. Of cource not backsticks! :-)
– Afsin Toparlak
Sep 10 at 18:15

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f467693%2fhow-to-execute-ln-on-find-results%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay