Kodi Community Forum

Full Version: Move script needed
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
To all, I have all my movies in one folder and I would like to do fanart and the like with .nfo files. Does anyone have a bash script that will run through all the movies and create a folder of the same name and move the file into that folder. I thought I saw a thread in here before but I could not find it anywhere. Thanks in advance.
Media companion is what you need.
Waffa Wrote:Media companion is what you need.

That's exactly the program you would use IN LINUX! Nod
Look, that program was a pretty decent undertaking and sorely needed. Yeah, it's Windows based because the programmer who did it apparently knew VB and he scratched an itch that many had - including myself. So far no one else has built anything like it that I'm aware of and the program works well enough to have handled almost 800 movies and a pile of TV shows on my system. It's a bit more than a bash script to say the least and so far no one seems to have done the same in Linux. Would you have preferred if the answer to the question was simply "NO, nothing exists" or was pointing to a Windows based program a better answer? I know what my preference is....
I am planning on using something like that to propagate the folders with info. I need a script that will take the movie, create a folder with the same name and then move that avi file into that folder.

Example

somemovie.avi
create folder somemovie
move somemovie.avi to somemovie folder.

I can then use media companion to finish off the rest.
Code:
#!/bin/sh

if [ -z "$1" ]; then
   echo "Usage: $0 <moviedir>"
   exit 1
fi


find "$1" -maxdepth 1 -name \*.avi -type f | while read m; do

   dir=`basename "$m" .avi`

   if [ ! -d "$1/$dir" ]; then
     echo "Moving $m"
     mkdir "$1/$dir", 0755
     mv "$m" "$1/$dir/"
   fi

done

The path to the movies in command-line need to be absolute.
Debug it with "echo" before using on your actual collection to make sure everything is going to be right..
even though this threat is quite old I just needed a script to do exactly this job

but there's a little fault in it
corrected version: (mkdir line changed)

Code:
#!/bin/sh

if [ -z "$1" ]; then
   echo "Usage: $0 <moviedir>"
   exit 1
fi


find "$1" -maxdepth 1 -name \*.avi -type f | while read m; do

   dir=`basename "$m" .avi`

   if [ ! -d "$1/$dir" ]; then
     echo "Moving $m"
     mkdir "$1/$dir" -m 0755
     mv "$m" "$1/$dir/"
   fi

done

Thanks a lot
I've pretty much copied what others did... I'm by no means any kind of expert at scripting:

#!/bin/sh
echo "This script moves videos and other file from the folder passed into a subdirectory with the filename"

if [ -z "$1" ]; then
echo "Usage: $0 <moviedir>"
exit 1
fi

for ext in .avi .xvid .divx .mov
do

find "$1" -maxdepth 1 \( -name \*$ext \) -type f | while read m; do

dir=`basename "$m" $ext`

if [ ! -d "$1/$dir" ]; then
echo "Moving $m"
mkdir "$1/$dir" -m 0755
fi

find "$1" \( -name "$dir.*" -o -name "$dir-fanart.jpg" \) -type f -print0 | xargs -0 mv -t "$1/$dir/"

done

done