Hello
My friend ask me about script of changing large files with sub directories with index of them like:
01 file1
02 file2
I try to do one but the "find" command when their files with spaces return to the for loop each part.
for example file like "hello world.txt" will split to "hello" and "world.txt"
How do I use in for in bash loop correctly?
If there is script like that you can tell me about it
Code:
#!/bin/bash
THIS=`basename "$0"`
NUMBER=0
for file in $( find -type f ); do
echo start loop
echo $file
FILENAME=`basename $file`
if [ "$FILENAME" = "" ]; then
echo problem
exit
fi
if [ "$FILENAME" = "$THIS" ]; then
continue
fi
DEST="`dirname $file`/$NUMBER $FILENAME"
echo "$DEST"
mv "$file" "$DEST"
let NUMBER+=1
done