Skip to main content
due to comment requests
Source Link
Ali Sh
  • 25
  • 1
  • 6

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.

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.

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.

Source Link
Ali Sh
  • 25
  • 1
  • 6

How to execute ln on find results

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.