|
Prev: Problem translating characters in file names
Next: How to remove specific file extensions recursively insubdirectories?
From: Nicole on 22 Jun 2008 18:57 The task at hand is renaming thousands of files within about one hundred directories and subdirectories, and I am sure there must be an easy way to do it from the command line, but right now I can't think of it and it's driving me mad... I need to get rid of two specific extensions that were added erroneously to the files: '_.don' and '.don' For instance, files that are now named 'report.kwd_.don' 'travel.html.don' and 'miami.txt._.don' must be moved to 'report.kwd' 'travel.html' and 'miami.txt' and, as I said, I need to process thousands of files like that in over a hundred directories and subdirectories that way. Is there a simple console command I can use within linux that will do all that recursively? Thank you so much for your help. Nicole
From: Nicole on 22 Jun 2008 19:50
On Jun 22, 4:33 pm, Dan Stromberg <dstrombergli...(a)gmail.com> wrote: > This isn't tested, and I've always done it the sed way, but rename looks > like a nice way of doing it now on Linux systems: > > find /dir/hier/archy -type f -print0 | xargs -0 rename _.don "" > find /dir/hier/archy -type f -print0 | xargs -0 rename .don "" > > Note though that there's apparently a perl command called rename with > different usage. The above is using the binary (probably a C program) > included with openSUSE 10.3 that's part of util-linux. Oh my God, it worked like a charm!!! Thank you! Thank you! Thank you! You made my day. Nicole |