0

I have a directory called "images" filled with about one million images. Yep.

I want to write a shell command to rename all of those images into the following format:
original: filename.jpg
new: /f/i/l/filename.jpg

Any suggestions?

Thanks,
Dan

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by sknake
0
#!/bin/bash
for i in *.jpg; do
  c1=`expr substr ${i} 1 1`
  c2=`expr substr ${i} 2 1`
  c3=`expr substr ${i} 3 1`
  dir=${c1}/${c2}/${c3}
  echo mkdir -p ${dir}
  echo mv $i ./$dir
done

You will want to test that the file name is at least 3 characters

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.