On 20Jan2015 19:37, Emil Payne <ehspayne@yahoo.com> wrote:
>I've looked up sed, awk & grep online, but they all work with files
>(the web pages, that is). How do I get them to work with a directory
>name?
You run "ls" (or suchlike) to generate a list of directories names.
Then you use sed or something on the list, then you run a shell script over the
result to make "mv" commands to rename things.
[...]
>The long string with the brackets and repetitive names is already
>created and sitting there. I just need to remove the repetitive
>information using the criteria mentioned. It does not need to read
>anything in the directory structure, just the current directory name.
Aside from your detailed "reverse my renaming" steps, have you considered just
brute force removing the duplication because you know the shapes of the
filenames.
If so, consider my "frename" script:
https://bitbucket.org/cameron_simpson/css/src/tip/bin/frename
(grab the "Raw" link at top right to download)
Then you can issue commands like this:
frename 's/2009}«{2009//g' *2009*2009*
or, given the regularity of your filenames:
frename 's/^(\d\d)«{(\d\d)}«{\d\d«{(\d\d\d\d).*/Pictures«Photos«$3-$1-$2/' *
Just an idea.
But FIRST, as a suggestion, take a copy of your tree (as almost zero cost!)
Of all your folders are in some superfolder called "foo" (for example), go to
above the superfolder and say:
cp -arl foo foo-NOT-RENAMED
This will make "foo-NOT-RENAMED" the same shape as your existing "foo" and with
all the files inside hardlinked, so not extra storage. Very fast and cheap.
Then if the renaming is a disaster, you can start again.
Cheers,
Cameron Simpson <cs@zip.com.au>
If you don't shoot the fish in your barrel, your barrel will soon be
full of fish. - Tim Mefford
Posted by: Cameron Simpson <cs@zip.com.au>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (13) |
No comments:
Post a Comment