How can I write a script that will move all .png .svg .gif files from /home/eric/Desktop to /usr/share/icons?
Asked
Active
Viewed 2,094 times
1
RolandiXor
- 51,797
era878
- 2,164
3 Answers
3
bash can handle this easily:
mv /home/eric/Desktop/*.{png,svg,gif} /usr/share/icons
Use sudo mv ... if you don't have permission to write into /usr/share/icons.
glenn jackman
- 18,218
0
As follows
#!/bin/sh
gksu mv /home/eric/Desktop/*.png /usr/share/icons & mv /home/eric/Desktop/*.svg /usr/share/icons & mv /home/eric/Desktop/*.gif /usr/share/icons & exit
I'm not a bash expert - but this should work. if it doesn't there is no warranty with my answer :P
RolandiXor
- 51,797
0
Why not use find? This worked for me:
find ./ -maxdepth 1 \( -iname "*.png" -o -iname "*.gif" -o -iname "*.svg" \) -ok cp {} /tmp/ \;
You want to mv not cp, and your destination is /usr/share/icons not /tmp but you can run this from the command line or a shell script.
-iname is case insensitive, -name would be case sensitive. Tweak the -maxdepth to your liking, and/or pull of the -ok clause to just see what it is coming up with.
Amanda
- 9,723