Gentoo Archives: gentoo-user

From: Stroller <stroller@××××××××××××××××××.uk>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Changing names of LOTS of files, adding to them actually.
Date: Fri, 02 Dec 2011 10:52:04
Message-Id: 39EFFC06-DEAF-4831-979C-28B847A29383@stellar.eclipse.co.uk
In Reply to: Re: [gentoo-user] Changing names of LOTS of files, adding to them actually. by Dale
1 On 1 December 2011, at 10:42, Dale wrote:
2 >> ...
3 >> sys-apps/renameutils should be installed on every system, IMO, and aliased thus in your .bashrc:
4 >>
5 >> alias qmv="qmv -f do"
6 >> alias qcp="qcp -f do"
7 >>
8 >> Set $EDITOR to vi, and renaming TV shows becomes quick and easy.
9 >
10 > vi? O_O Would nano not work? I got stuck in vi once. I felt like I was in Hotel California. :/ Got that tune in your head now huh? lol
11 >
12 > I'm going to see what else is available too. I bet since Krename is installed, rename is installed too. I'm sure Krename is just a GUI front end to something already on here.
13
14 nano would work.
15
16 When you use renameutils in --format=destination-only (`-f do`) mode, you just get a list of current file names in your text editor. You change them to the new names you desire and when you save the text file (and exit) the rename is completed. If you make such an error that you don't want the changes to apply you exit the text editor without saving.
17
18 The reason that vi or vim is recommendation-worthy is that you can do advanced search and replace and save macro functions for (for example) fixing capitalisation [1] or changing underscores or periods to spaces.
19
20 It would be easy, for example, to save a function in your .vimrc to change every instance of SxxEyy (e.g. S01E13) to "Season xx - Episode yy".
21
22 Sure, you can do all this with the other tools suggested by others, but each time you're going to have to use the mouse to select the "from" box in the GUI, then type "_", then mouse to the "to" box and type " " and so on. You're going to be performing the same handful of identical functions each time. In vim you can save these and activate them with the f2, f3, f4 keys.
23
24 An advantage of using the search and replace within a text editor is that you'll be able to see these kinds of automatable filename changes *alongside* edits that you'll want to make manually, and you can see the results immediately. So if you misdo the search and replace you can just use vim's undo command, and then redo the replace with the same starting point you used before. This is clearly much better than realising that "whups! i've renamed all these files wrongly now" and having to work out the correct regrex based on their new filenames.
25
26 Finally, when you're dealing with whole series of TV shows, the ability to select by column, or to insert the same text at the same place on several different lines should not be underestimated.
27
28 Stroller.
29
30
31
32 [1] http://vim.wikia.com/wiki/Switching_case_of_characters#Twiddle_case

Replies

Subject Author
Re: [gentoo-user] Changing names of LOTS of files, adding to them actually. Frank Steinmetzger <Warp_7@×××.de>