Hello everyone,
I wrote the following scrip to rename some jpg files to what I hope
is a better organized way to keeping up with them.
Code:
#!/bin/bash
# Scrip to rename jpg files
num=1
x=$(date +%m%d%y)
skip=${x}
for file in *.jpg; do
if [ "${file%_*.jpg}" = "$skip" ]; then
echo Skipping file $file
let num++
continue
fi
if [ $num -le 9 ]; then
mv "$file" "${x}_n00${num}.jpg"
echo Moving $file
fi
if [ $num -ge 10 ]; then
mv "$file" "${x}_n0${num}.jpg"
echo Moving $file
fi
let num++
done
The way I have written the scrip is to use the date as the prefix
for the file and later on I plane to use "read" in the scrip so
I can enter other "older dates" for my archive of files.
Now, for my problem as you can see the first "if" statement skips the
files with the prefix of the current date. This is "not" what I want,
but for testing purposes it was what I could understand. I want the
first if statement to skip the files that have the "format" of the
date command. So any file that has "six numbers" before a "_" will be
skipped.
Thanks in advance.