Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Making directories
- #mkdir -p /home/abhisek/images
- #mkdir -p /home/abhisek/videos
- #mkdir -p /home/abhisek/documents
- # Finding all image files
- for file in `find /home/abhisek -name '*' -exec file {} \; | grep -o -P '^.+: \w+ image' | cut -d ':' -f 1`
- do
- cp $file /home/abhisek/images &> /dev/null
- done
- # How to extend this script
- # Run:
- # find /home/abhisek -name '*' -exec file {} \;
- # Replace the path /home/abhisek with desired path
- # Note the file format at the end of each line
- # Then replace grep -o -P '^.+: \w+ image' with the file format you want to filter
- # Replicate the for loop to extend the script
- # How to trigger the script when you insert the a drive
- # Start by finding your device in lsusb. Note the ID (eg 0a81:0101)
- # Create a new udev rules file in /etc/udev/rules.d/ by
- # sudoedit /etc/udev/rules.d/100-mount-videos.rules
- # add a new rule in there like this:
- # ACTION=="add", ATTRS{idVendor}=="0a81", ATTRS{idProduct}=="0101", RUN+="/home/your_username/bin/myscript.sh"
Add Comment
Please, Sign In to add comment