So here's the deal, my girlfriend wants me to transfer all of her photos off from her iPhone onto her laptop (on which we are running Ubuntu 14.04). All of the dedicated programs I tried to do this with did not work, so I just copied the entire DCIM/ folder, which contains all of the pictures on her iPhone. My predicament is that DCIM/ is divided into four folders, which then contain an individual folder for each of her photos. In each of those folders, every picture has the same name, '5003.jpg'.I want to move and rename (probably with ascending numerical names, e.g. 0001.jpg, 0002.jpg, etc.) all of these files to one folder, say ~/Pictures/iPhone/, using the command line.So far all i've managed to do is compile a text file of all the individual paths for each file.Some example path names:/home/jennie/Pictures/DCIM/101APPLE/IMG_1703.JPG/5003.JPG/home/jennie/Pictures/DCIM/101APPLE/IMG_1431.PNG/5003.JPG/home/jennie/Pictures/DCIM/101APPLE/IMG_1933.JPG/5003.JPG/home/jennie/Pictures/DCIM/101APPLE/IMG_1388.JPG/5003.JPG/home/jennie/Pictures/DCIM/101APPLE/IMG_1954.JPG/5003.JPG/home/jennie/Pictures/DCIM/101APPLE/IMG_1524.JPG/5003.JPG/home/jennie/Pictures/DCIM/101APPLE/IMG_1897.PNG/5003.JPG/home/jennie/Pictures/DCIM/101APPLE/IMG_1582.PNG/5003.JPG/home/jennie/Pictures/DCIM/101APPLE/IMG_1007.PNG/5003.JPG/home/jennie/Pictures/DCIM/101APPLE/IMG_1502.JPG/5003.JPG
Moving and renaming hundreds of .jpg files, all named 5003.jpg
bash;shell;command line;files;rename
#!/bin/bashappledir=$HOME/Pictures/DCIM/101APPLEjpgname=5003.JPGfor   dir   in $appledir/*do    if    [[ -d $dir ]]      then          newfile=$appledir/${dir##*/}          mv $dir/5003.JPG $newfile.tmp &&          rmdir $dir &&          mv $newfile.tmp $newfile      fidoneWith an initial tree as this:$ tree Pictures/Pictures/ DCIM     101APPLE         IMG_1002.JPG          5003.JPG         IMG_1003.JPG          5003.JPG         IMG_1004.JPG             5003.JPGAfter executing the script (./script.sh), this will be the tree:$ tree Pictures/Pictures/ DCIM     101APPLE         IMG_1002.JPG         IMG_1003.JPG         IMG_1004.JPGEdit:To rename *.PNG files back to *.JPG, use:for     name   in $HOME/Pictures/DCIM/101APPLE/*.PNGdo      mv -i $name ${name%PNG}JPGdone