Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #noParity=true
- #arrayStarted=true
- ## This script will create folders from files. IT will process all files in the FROM location
- ## Later I might build in a filter, but currently it process all files
- ## It will also move files/directories to final location if you uncomment down in the code
- ## It will also change your file permissions from root to nobody uncomment below to use
- ## Adjust your directories below for your needs.
- ## Have Questions ask kizer on unraid forum
- ## All code has been cobbled together by me and tested on my own system to insure it works
- ## Source Directory of Files, change below to your path. I left mine in for example
- FROM=/mnt/cache/HandBrake/Blah
- ## Script will leave renamed files where they are unless you comment and adjust below
- ## Keep in mind you have to uncomment below
- ## Only if you want to move new folder to another location. Change below to your path
- ## and uncomment near the very bottom of this script
- NEWLOCATION=/mnt/cache/HandBrake/Blah-old
- cd $FROM
- for f in *.*
- do
- subdir=${f%%.*}
- [ ! -d "$subdir" ] && mkdir -- "$subdir"
- mv -- "$f" "$subdir"
- ######################## OPTIONAL BELOW #################
- ## Remove Pound symbol option you would like to use down below
- ## Change Permissions so Everything is Happy
- ## Changes from read write from ROOT
- chmod -R u-x,go-rwx,go+u,ugo+X "$subdir"
- ## Changes owner from ROOT to Nobody which is pretty standard on unraid
- chown -R nobody:users "$subdir"
- mv "$subdir" $NEWLOCATION/
- ###################### DONE OPTIONAL ####################
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement