I'm controlling a Linux based NAS through SSH on a Windows computer. What I'm trying to do is use the cp -al command to rapidly copy folders from one directory to another, hardlinking all the files inside. Currently what I do is I list the directory with ls, then I highlight it with my mouse, copy it with right click, then paste it back in, for example if I'm hardlinking a directory called "Madagascar.2005.1080p.BluRay.DTS.x264" I would copy only the name of that directory, then manually write out
cp -al "sourceDir/Movie/
then I paste in the "Madagascar.2005.1080p.BluRay.DTS.x264". I do the same for the second directory to build the whole command:
cp -al "sourceDir/Madagascar.2005.1080p.BluRay.DTS.x264" "dstDir/Movie/Madagascar.2005.1080p.BluRay.DTS.x264"
This whole process is pretty cumbersome, and feels unnatural when everything else done on linux shell is done without the mouse.
Is there a better way of building this long command without having to copy and paste things using the mouse, or to type out entire names manually?
edit: I do not want to delete the source directory. The source directory looks like this aproximately:
'Lost S04 720p BluRay DTS x264
Lost.S03.720p.BluRay.DTS.x264
'Million.Dollar.Extreme.Presents.World.Peace.S01.1080p'
'The Simpsons S01 1080p DSNP WEBRip DDP5.1 x264'
'The Simpsons S02 1080p DSNP WEBRip DDP5.1 x264'
I will be changing the source or destination directories frequently.
ls
command. Is this the only entry in sourceDir, or is there other content? Is the target always dstDir/Movie ? Do you want to remove the sourceDir entry afterwards? – Stephen Harris May 25 '22 at 22:04cp -al {sourceDir,dstDir}/Madagascar.2005.1080p.BluRay.DTS.x264
– muru May 26 '22 at 06:48find ... -exec ...
twice (once to make the all the directories, once to hardlink all the files). But maybe you want to do something different, I still don't know. – dirkt May 26 '22 at 07:06