Advertisement
Available-Elevator69

Untitled

May 24th, 2023
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.56 KB | None | 0 0
  1. #!/bin/bash
  2. #noParity=true
  3. #arrayStarted=true
  4.  
  5. ## This script will create folders from files. IT will process all files in the FROM location
  6. ## Later I might build in a filter, but currently it process all files
  7. ## It will also move files/directories to final location if you uncomment down in the code
  8. ## It will also change your file permissions from root to nobody uncomment below to use
  9. ## Adjust your directories below for your needs.
  10. ## Have Questions ask kizer on unraid forum
  11. ## All code has been cobbled together by me and tested on my own system to insure it works
  12.  
  13. ## Source Directory of Files, change below to your path. I left mine in for example
  14. FROM=/mnt/cache/HandBrake/Blah
  15.  
  16. ## Script will leave renamed files where they are unless you comment and adjust below
  17. ## Keep in mind you have to uncomment below
  18.  
  19. ## Only if you want to move new folder to another location. Change below to your path
  20. ## and uncomment near the very bottom of this script
  21. NEWLOCATION=/mnt/cache/HandBrake/Blah-old
  22.  
  23. cd $FROM
  24.  
  25. for f in *.*
  26. do
  27.   subdir=${f%%.*}
  28.   [ ! -d "$subdir" ] && mkdir -- "$subdir"
  29.   mv -- "$f" "$subdir"
  30.  
  31. ######################## OPTIONAL BELOW #################
  32. ## Remove Pound symbol option you would like to use down below
  33. ## Change Permissions so Everything is Happy
  34.  
  35. ## Changes from read write from ROOT
  36. chmod -R u-x,go-rwx,go+u,ugo+X "$subdir"
  37. ## Changes owner from ROOT to Nobody which is pretty standard on unraid
  38. chown -R nobody:users "$subdir"
  39.  
  40. mv "$subdir" $NEWLOCATION/
  41.  
  42. ###################### DONE OPTIONAL ####################
  43.  
  44. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement