views:

40

answers:

1

Purpose:

  • change names of all files in a directory to random strings of the same length
  • list this files in another file (with a possibility to make from it sql query )

I think bash would be great for it, but I have no idea how to do this, can you help me?

A: 

So many ways... for example:

random_string() { 
  echo "$(date +%s%N)$RANDOM" | md5sum | awk '{print $1}' 
}

find /path/to/files -type f | while read FILE; do 
  EXTENSION=${FILE##*.}
  mv "$FILE" "$(dirname "$FILE")/$(random_string).$EXTENSION"
done
tokland