Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This bash script will rename and convert the jpg files in the newest directory in the current directory and the files in the first level of directories under that directory.</p> <pre><code>#!/bin/bash FIRST_DIR=`ls -t1F | grep / | head -n1` DIR="./${FIRST_DIR}" ls -t1F $DIR | while read -r FILE do if [ "$FILE" ] then if [[ $FILE = */ ]] then echo "here ${DIR}${FILE}." DEEP_DIR="${DIR}${FILE}" ls -t1 $DEEP_DIR | while read -r FILE2 do if [ "$FILE2" ] then if [[ $FILE2 != */ ]] then RENAME=`echo ${FILE2//\*/} | tr ' ' '_' ` mv -v "${DEEP_DIR}${FILE2//\*/}" "${DEEP_DIR}${RENAME}" FILE2=$RENAME RENAME2=`echo ${FILE2//\*/} | tr '\*.JPEG' '\*.jpg' ` mv -v "${DEEP_DIR}${FILE2//\*/}" "${DEEP_DIR}${RENAME2}" FILE2=$RENAME2 fi fi done mogrify -resize 750 "$DEEP_DIR*.jpg" wait jpegoptim "$DEEP_DIR*.jpg" –max=70 --strip-all fi if [[ $FILE != */ ]] then RENAME=`echo ${FILE//\*/} | tr ' ' '_' ` mv -v "${DIR}${FILE//\*/}" "${DIR}${RENAME}" FILE=$RENAME RENAME2=`echo ${FILE//\*/} | tr '\*.JPEG' '\*.jpg' ` mv -v "${DIR}${FILE//\*/}" "${DIR}${RENAME2}" FILE=$RENAME2 fi fi done if [ "$FIRST_DIR" ] then mogrify -resize 750 "$DIR*.jpg" wait jpegoptim "$DIR*.jpg" –max=70 --strip-all fi </code></pre> <p>Here are a couple of good links about bash programming:</p> <p><a href="http://tldp.org/LDP/abs/html/comparison-ops.html" rel="nofollow">http://tldp.org/LDP/abs/html/comparison-ops.html</a></p> <p><a href="http://tldp.org/LDP/abs/html/string-manipulation.html" rel="nofollow">http://tldp.org/LDP/abs/html/string-manipulation.html</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload