How to execute ln on find results
Clash 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.
find symlink php
add a comment |Â
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.
find symlink php
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 commandln -sf path/to/file/microlancer.png path/to/symlink/microlancer.png
on the images one by one?
â Goro
Sep 8 at 11:51
add a comment |Â
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.
find symlink php
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
find symlink php
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 commandln -sf path/to/file/microlancer.png path/to/symlink/microlancer.png
on the images one by one?
â Goro
Sep 8 at 11:51
add a comment |Â
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 commandln -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
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
find /path/to/file -name '*.png' -exec ln -s '' /path/to/symlink ';'
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
add a comment |Â
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 ';'
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
add a comment |Â
up vote
0
down vote
accepted
find /path/to/file -name '*.png' -exec ln -s '' /path/to/symlink ';'
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
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
find /path/to/file -name '*.png' -exec ln -s '' /path/to/symlink ';'
find /path/to/file -name '*.png' -exec ln -s '' /path/to/symlink ';'
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
add a comment |Â
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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