Rename a file with parentdir name
Dear all,
I have several ABC.ps files that I would like to transform into pdf for visualization reasons. Each of them is in a different directory and all of them are called exactly ABC.ps: /../alpha/ABC.ps /../beta/ABC.ps /../gamma/ABC.ps .. I want them to have the directory name as filename, so that it will be easy for me to pick up the ones I need to see with acroread, once ps2pdfed them. Would you use mv for example? But how can I tell it to get the dirname? I've tried several options, including baseline ´pwd` but with no wayout. I would start with: Code:
for i in ${ls */ABC.ps} Code:
for i in ${ls */ABC.ps} Sincerely, Udiubu |
Code:
find /path/to/files -type f -iname \*.ps -printf "echo mv \"%p\" \"%h/\$(basename %h)_%f\"\n" |
Don't use ls to feed a for loop. It can be hazardous for your health ;)
I would do it this way: Code:
# This is where all PDFs will be put |
414N, it works beautifully!
So to clarify: Quote:
Best, Udiubu |
Those are special parameters expansion (you can find more info about them and the like under the "PARAMETER EXPANSION" section of the man page for bash) used to remove some patterns.
Specifically:
|
Wow, well clear.
|
All times are GMT -5. The time now is 06:37 PM. |