GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   anyone wanna lend a hand with this shell script? (https://gfy.com/showthread.php?t=1010416)

fris 02-15-2011 08:28 AM

anyone wanna lend a hand with this shell script?
 
basically what it does is takes a directoryof images

kajskj.JPG
evilbunny.gif
anothername.png
funnypic.jpeg

and renames them to 1.JPG, 2.gif 3.png 4.jpeg

what i want to do is make the 1.JPG to 1.jpg and 4.jpeg to 4.jpg

this is what i have so far, it does what i want except for the .JPG and .jpeg part.

Code:

i=1; shopt -s nullglob; for f in *.jpg *.gif *.png *.jpeg *.JPG *.JPEG *.GIF; do mv -- "$f" "$i.${f##*.}"; ((i++)); done

fris 02-15-2011 09:03 AM

nm figured it out
Code:


    i=1;
    shopt -s nullglob;
    for f in *.jpg *.gif *.png *.jpeg *.JPG *.JPEG *.GIF; do
        EXT="${f##*.}"
        EXT=${EXT,,}
        EXT=${EXT/jpeg/jpg}
        mv -- "$f" "$i.${EXT}";
        ((i++));
    done


Juicy D. Links 02-15-2011 10:10 AM

Pussy lips i did it loloolololl

Code:

  i=1;
    shopt -s nullglob;
    for f in *.jpg *.gif *.png *.jpeg *.JPG *.JPEG *.GIF; do
        EXT="${f##*.}"
        EXT=${EXT,,}
        EXT=${EXT/jpeg/jpg}
        mv -- "$f" "$i.${EXT}";
        ((i++));
    done


fris 02-15-2011 11:37 AM

Quote:

Originally Posted by Juicy D. Links (Post 17916808)
Pussy lips i did it loloolololl

Code:

  i=1;
    shopt -s nullglob;
    for f in *.jpg *.gif *.png *.jpeg *.JPG *.JPEG *.GIF; do
        EXT="${f##*.}"
        EXT=${EXT,,}
        EXT=${EXT/jpeg/jpg}
        mv -- "$f" "$i.${EXT}";
        ((i++));
    done


could shorten it by doing for f in *.{jpg,jpeg,JPG,JPEG,gif,GIF,png,PNG};

Juicy D. Links 02-15-2011 12:32 PM

Quote:

Originally Posted by fris (Post 17917022)
could shorten it by doing for f in *.{jpg,jpeg,JPG,JPEG,gif,GIF,png,PNG};

I concur :1orglaugh:1orglaugh

V_RocKs 02-15-2011 02:11 PM

Juicy for pres!


All times are GMT -7. The time now is 03:39 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123