papun

Untitled

Jul 2nd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.02 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Making directories
  4. #mkdir -p /home/abhisek/images
  5. #mkdir -p /home/abhisek/videos
  6. #mkdir -p /home/abhisek/documents
  7.  
  8. # Finding all image files
  9. for file in `find /home/abhisek -name '*' -exec file {} \; | grep -o -P '^.+: \w+ image' | cut -d ':' -f 1`
  10.   do
  11.     cp $file /home/abhisek/images &> /dev/null
  12.   done
  13.  
  14. # How to extend this script
  15. # Run:
  16. # find /home/abhisek -name '*' -exec file {} \;
  17. # Replace the path /home/abhisek with desired path
  18. # Note the file format at the end of each line
  19. # Then replace grep -o -P '^.+: \w+ image' with the file format you want to filter
  20. # Replicate the for loop to extend the script
  21.  
  22. # How to trigger the script when you insert the a drive
  23. # Start by finding your device in lsusb. Note the ID (eg 0a81:0101)
  24. # Create a new udev rules file in /etc/udev/rules.d/ by
  25. # sudoedit /etc/udev/rules.d/100-mount-videos.rules
  26. # add a new rule in there like this:
  27. # ACTION=="add", ATTRS{idVendor}=="0a81", ATTRS{idProduct}=="0101", RUN+="/home/your_username/bin/myscript.sh"
Add Comment
Please, Sign In to add comment