I have a large "myfiles" directory full of miscellaneous documents and do not want to modify its structure.
I therefore created (several) other directories for each class of documents. For example, I have an "images" directory which has symlinks to each .jpg
or .cr2
file in the "myfiles" directory plus other descriptive files for each symlink (with the same filename) with description and other metadata. The symlinks in the /images directory might have a different name from the original linked file.
I am trying to find the simplest way to make sure each and every image file in the "myfiles" directory has a symlink into the "images" directory.
See an example of the folder structure
/myfiles/a.doc
/myfiles/b.jpg
/myfiles/c.cr2
/myfiles/d.mov
should result
/images/b_800x600.jpg
/images/b_800x600.desc
/images/c_3820x5640.cr2
/images/c_3820x5640.cr2
find /myfiles -type f
to a file then usefind /images -type l -exec readlink {} \; | egrep myfiles
to get a list of files that are symlinked in/images
then iterate over the results doing ased
on each one to delete the paths in the first file you save since they already have the symlink and the files left over are the files that don't have the symlink.ls -l
you can see the hardlink count in the second column.rm
those symlink dirs and usepax -rwl -s "\|.*regex|modifes_filename|" /path/to/myfiles/*.jpg /path/to/jpg_dir
for example to get hardlinks with programmatically altered filenames for only those that files that match your jpgs. You can get a lot more than that out of it - like batching based on change times and etc.