joshpond Posted December 21, 2011 Posted December 21, 2011 Hi All, I have a user share, TV Shows and there are all these .jpg files in different subfolders for YAMJ. I'd like to delete all these file types but not sure what the command line would be. I'm guessing it is the -r switch to delete all .jpg files: rm -r *.jpg Thanks Josh
eph85 Posted December 21, 2011 Posted December 21, 2011 If you just want to delete jpg files in the current directory, all you need to do is rm *.jpg The -r option tells the rm command to recurse down through all sub-directories below your current directory and delete the jpg files in those directories as well, so don't use it if you only want to delete files in your current directory. A client of mine once ran "rm -r *" in the root directory. They didn't realize until I told that they had deleted _all_ files on their system. It's a very dangerous command. (Fortunately it was only a test system and they had a backup.)
joshpond Posted December 21, 2011 Author Posted December 21, 2011 Thanks, that was what I was after. -r was the switch I wanted. I want to delete all .jpg files as they are scattered in diff directories for the nfo/metadata. I just want to keep the movie files like avi and isos. Thanks Josh
joshpond Posted December 21, 2011 Author Posted December 21, 2011 root@Ho:/mnt/user/Media/TV Shows# rm -R *.jpg rm: cannot remove `*.jpg': No such file or directory Okay, Doesn't quite work, this is what I get. Under the TV shows directory there are folders for each TV show. Josh
kizer Posted December 21, 2011 Posted December 21, 2011 Here is a link for you to take a look at. http://www.linuxquestions.org/questions/linux-general-1/how-to-do-recursive-file-delete-using-specifier-*-tmp-from-nested-directories-290602/
WeeboTech Posted December 22, 2011 Posted December 22, 2011 It would be better with the find command. Read up on find. Try something like find '/mnt/user/Media/TV Shows' -type f -name '*.jpg' -ls This will list all your files that match the specs. If it's what you want you can do find '/mnt/user/Media/TV Shows'-type f -name '*.jpg' -ls -exec /bin/rm -vi {} \; or you could take away the -vi and just do -v The quotes are necessary, and so is the semicolon.
joshpond Posted December 22, 2011 Author Posted December 22, 2011 Thanks guys, That did the trick. Josh
settings Posted January 5, 2012 Posted January 5, 2012 This is the line I use to keep all them pesky windows thumbs out of my unraid find /mnt/disk1/Movies/* -type f -name "Thumbs.db" -exec rm {} \; although looking at Weebos would this one be better? find '/mnt/disk1/Movies/' -type f -name 'Thumbs.db' -ls -exec /bin/rm -vi {} \; Just wondering is there a forum here on useful scripts for unraid users? I was looking for one yesterday and couldn't find anything. I got some scripts that im sure some people would find useful, like creating a log of everything copied to your drives (from cache) so it would be like tv added Jan 5th .... etc. I also got a script to update my external drive media added in the last x amout of days etc. A script to install and ready addons like snap etc when I reboot. Just thought it would be good to share and people could improve them/post their own etc
WeeboTech Posted January 5, 2012 Posted January 5, 2012 See the User Customizations forum http://lime-technology.com/forum/index.php?board=6.0 As far as which find line is better. Mine just documents what is being deleted so you can save it to a log. It also does not wildcard the directories at the find command (it still traverses the directories) Furthermore, since I use the full path of /bin/rm a path search is eliminated.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.