I have a group of directories, each containing exactly 1 jpeg image, like so-/psds/folder1/image.jpg/psds/someotherfolder/picture.jpg/psds/yetanotherfolder/thumbnail.jpgWhat is the appropriate way to rename the jpegs to the name of their containing folder? What I want is:/psds/folder1/folder1.jpg/psds/someotherfolder/someotherfolder.jpg/psds/yetanotherfolder/yetanotherfolder.jpg
Shell Scripting: how to use part of the file path as the file name?
shell script;files;rename;filenames
Run the below commands inside /psds directory.for f in ./*; do    if [ -d $f ] ; then        cd $f        mv *.jpg $f.jpg        cd ..    fidoneIf you have 3 folders inside /psds directory like below,/psds/folder1/image1.jpg/psds/folder2/image2.jpg/psds/folder3/image3.jpgAfter you run the above command, the files would be renamed as,/psds/folder1/folder1.jpg/psds/folder2/folder2.jpg/psds/folder3/folder3.jpg