Move Movies into folders


Recommended Posts

@squirrellydw

 

Here is the code I currently use in one of my projects that runs nearly hourly to take the output of a Handbrake job and move it to its finally location Spaces Removed and replaced with a . and dropped into a folder that has the file name as its on.

Transformers.(2007)(1080).mp4  will become

Transformers.(2007)(1080)/Transformers.(2007)(1080).mp4 

 

#!/bin/bash

find /mnt/user/HandBrake/ZZZZZ -maxdepth 1 -type f -mmin +5 -exec mv {} /mnt/user/HandBrake/ZZZZZ/move2travel/ \;

#Remove Spaces and throw into move2travel folder
cd /mnt/user/HandBrake/ZZZZZ/move2travel/
for f in *\ *; do mv "$f" "${f// /.}"; done

#Create Folder from name and move to final location. File types editable below. We don't like spaces so the above had to work. 
for FILE in `ls /mnt/user/HandBrake/ZZZZZ/move2travel/ | egrep "mkv|mp4|avi|vob|iso|MKV|MP4|AVI|VOB|ISO"`
do
DIR=`echo $FILE | rev | cut -f 2- -d '.' | rev`
mkdir /mnt/disks/TOWER_Travel/$DIR
mv /mnt/user/HandBrake/ZZZZZ/move2travel/$FILE /mnt/disks/TOWER_Travel/$DIR
done

1 . First line moves all files, but insures that a file hasn't been touched for at least 5minutes because HandBrake might be processing it and I didn't want this script to move a file being written to. 

 

2. Now to give you a clue what is going on . I created couple of folders.

move2travel which is a temporary folder that pulls from a folder named ZZZZZ to remove spaces before it removes all spaces and then shovels it off to its final destination folder which I called TOWER_Travel

 

Anyways if you need any help or have any questions on my Bubble Gum, Duct Tape coding skills feel free to ask away. :D

This code Does not like Spaces so I had to remove them. 

 

HandBrake Share

/dump

/ZZZZZ

/ZZZZZ/move2travel

 

Move Share

/HD

/Travel aka SD versions

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.