I have many files with the same name, with this directory structure (simplified):
../foo1/bar1/dir/file_1.ps ../foo1/bar2/dir/file_1.ps ../foo2/bar1/dir/file_1.ps .... and many more
As it is extremely difficult to browse all these ps files by going to the appropriate directory, I would like to copy all of them to another directory, but include the name of the first two directories (which match my purpose) in the file name.
I previously tried like this, but I canβt get which file is coming from, since they are all indicated sequentially:
Where ../plots is the folder in which I copy them. However, they now have the form file.ps. ~ x ~ (x is a number), so I get rid of ".ps. ~ * ~" and leave only the ps extension with:
rename 's/\.ps.~*~//g' *; rename 's/\~/.ps/g' *;
Then, since ps files sometimes have hundreds of points and take a lot of time, I just convert them to jpg.
for file in * ; do convert -density 150 -quality 70 "$file" "${file/.ps/}".jpg; done;
This does not work bash script, since I need to manually change the directory.
I think the best way to do this is to copy the files from the beginning with the names of the first two directories included in the copied file name.
How can I do this last?
source share