I have 31 directories from sample1 to sample31 with similar naming files.
❯ find . -maxdepth 2 -type f ./sample5/palette-david-clode-2B4dYFgYAyQ-unsplash.thumbnail.jpg ./sample5/david-clode-2B4dYFgYAyQ-unsplash.jpg ./sample5/david-clode-2B4dYFgYAyQ-unsplash.thumbnail.jpg ./sample2/amy-syiek-0n9lbdiAKi0-unsplash.jpg ./sample2/amy-syiek-0n9lbdiAKi0-unsplash.thumbnail.jpg ./sample2/palette-amy-syiek-0n9lbdiAKi0-unsplash.thumbnail.jpg ./sample3/marc-meyer-9JE6BLqMYYM-unsplash.thumbnail.jpg ./sample3/palette-marc-meyer-9JE6BLqMYYM-unsplash.thumbnail.jpg ./sample3/marc-meyer-9JE6BLqMYYM-unsplash.jpg ...more files Now I'd like to
change all files starting with
palette-topalette.jpg. Foe example:./sample5/palette-david-clode-2B4dYFgYAyQ-unsplash.thumbnail.jpgto./sample5/palette.jpg.change all files ending with
.thumbnail.jpgtosample.jpg. For example:./sample5/david-clode-2B4dYFgYAyQ-unsplash.thumbnail.jpgto./sample5/sample.jpg.
How can I do this on the terminal?
I tried this but didn't work:
for dir in */; do; for file in "palette-*.jpg"; do mv "$file" "palette.jpg"; done;for file in "*.thumbnail.jpg"; do mv "$file" "sample.jpg";done;done Result:
mv: rename palette-*.jpg to palette.jpg: No such file or directory mv: rename *.thumbnail.jpg to sample.jpg: No such file or directory mv: rename palette-*.jpg to palette.jpg: No such file or directory mv: rename *.thumbnail.jpg to sample.jpg: No such file or directory mv: rename palette-*.jpg to palette.jpg: No such file or directory ...
palette-david-clode-2B4dYFgYAyQ-unsplash.thumbnail.jpghave been renamed intosample.jpgaccording to the first rule - so the 2:nd rule wouldn't get the chance to rename it intopalette.jpg?palette-move topalette.jpg. So move them first then move*.thumbnail.jpgtosample.jpg?1and2? Do2first, then1?