Jump to content

Multiple files to folder script


Filth

Recommended Posts

Posted

Hi guys,

I have trouble with this script, which is supposed to create a directory based on the file name, then move that file into the directory.

 

#!/usr/bin/bash
find . -name '*.*' | \
while read filename
do
      mkdir "${filename%.*}"
      directory=${filename%.*}
      mv "$filename" "$directory"/"$filename"
done

I get the following error when running it, does unraid have a "do" command?

 

-bash: syntax error near unexpected token `do'

 

 

cheers,

Filth.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...