How can I write a script that will move all .png .svg .gif
files from /home/eric/Desktop
to /usr/share/icons
?
3 Answers
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.
-
-
-
Needs a maniacal laugh at the end of that comment, ala Dr. Evil from Austin Powers or something 8-)– slmMar 26, 2014 at 2:43
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
-
-
1That's an sh script, not a bash script, and there's no point in running the
mv
s in parallel. I'd make a bash-script that doesshopt -s extglob
and thenmv ~eric/Desktop/*.@(png|svg|gif) /usr/share/icons/
– geirhaMar 15, 2011 at 7:15 -
-
i'd use 'sudo' instead of 'gksu' in a shell script. im no expert either. Mar 22, 2011 at 21:41
-
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.