2004.08_Krename-File or Batch Renaming and Permission Changing.pdf
(
2510 KB
)
Pobierz
Layout 1
LINUX USER
KTools
Move and Rename
“The batch renamer for KDE 3.x”, this is how the KRename KDE tool describes
itself. However, it can do more than the name suggests: from simple file
renaming, to permission modifications for as many files as you like – all at one
fell swoop.
BY STEFANIE TEUFEL
and easily done, assuming you
just need to rename a couple of
files. Renaming a large number of files
and directories is more time-consuming.
Thanks to KRename, users can leverage
the power of a
batch
renamer with the
typical KDE look & feel to modify a list of
filenames by reference to a user-defin-
able template.
There is more to come: KRename can
also copy or move files to another direc-
tory, renaming either the target or source
files. A single mouse click allows you to
change filename capitalization, add
numbers, and search and replace strings
within filenames. Finally, KRename also
supports changes to the last accessed, or
last modified timestamps, file permis-
sions and ownership.
You can download the latest version of
this useful tool from the project home-
page at
http://www.krename.net/3.0.
html
. As the program is under active
development, you will also find the cur-
rent developer version at the same place.
This article is based on the current stable
version 2.8.5.
In addition to the sources, the develop-
ers also have RPM packages for most
major distributions, so installing the tool
should not pose any problems. If the
download section does not have a pack-
age for your system, follow the normal
steps,
configure; make; make install
, to
build KRename from source code. You
will need to point the program in the
direction of your KDE directories by set-
ting the
KDEDIRS
environment variable,
for example:
to select a user interface (see Figure 1).
Keep the default,
Use wizard style GUI
(beginners)
, if you want KRename to dis-
play a whole bunch of dialogs to guide
you through the rename process.
After getting used to the program, you
can switch to
Use tabbed GUI (advanced
users)
in
Settings | Configure KRename…
| Look and Feel
to group the dialogs
described in the following sections as
tabs in a single window.
Ta k e a quick look at the
KRename
function in the preferences dialog. If you
check the
Add KRename to konquerors
context menu
checkbox, you will not
need to launch the program in future.
Instead, you can simply select the
Rename with krename
context menu
entry in KDE file dialogs, and in Kon-
queror. This menu appears when you
right click a file that you want to rename.
Adding Files for Renaming
Before you can rename files, you need to
add them to the list in the dialog box.
export KDEDIRS=/opt/kde3:/usr
U
/local/kde
After completing the install, you can
either launch KRename via the
Tools |
Krename
entry in the K menu, or by typ-
ing
krename
in your favorite terminal
emulation. When you launch KRename
for the first time, the program asks you
KTools
Figure 1: Beginners should opt for the Wizard.
In this column we present tools, month by
month, which have proven to be especially
useful when working under KDE, solve a
problem which otherwise is deliberately
ignored, or are just some of the nicer things
in life, which – once discovered – you would
not want to do without.
Figure 2: Use this dialog to specify what to do
with the original files.
76
August 2004
www.linux-magazine.com
Modifying filenames and attributes with KRename
R
enaming files is a common task
KTools
LINUX USER
Figure 3: KRename’s functionality is extensible thanks to a huge selection of
plug-ins.
Figure 6: After renaming, the PNG image filenames include bit depth
information.
There are various approaches to doing
this. You can click the
Add files…
button
to fill the empty list using the file section
dialog. You can select one file or multiple
files. Clicking
Add directory…
will add
the total content of the directory to your
list. If you prefer, you can simply drag &
drop files into the list. After completing
your selection, the next step, after click-
ing the Next button, is to specify a target
location for the renamed files. Again
there are a number of options (see Figure
2):
Rename input files
renames the origi-
nal files in the list,
Copy files to
destination directory
keeps the original
names, but moves the files to the target
directory and renames the copies.
If you opt for
Move files to destination
directory
, the original files are moved to
the target directory and then renamed.
The fourth option
Create symbolic links
in destination directory
keeps the origi-
nal files in their original location, as
KRename simply sets up
symbolic links
for the files in the target directory.
If you click on the
Finish
button after
selecting a target, you are in for a
surprise (see Figure 3). KRename uses
KDE plug-in technology. Depending on
your KDE version, you should have a
selection of various plug-ins at this stage.
PNG-Info
or the
Picture Plugin
can be
extremely useful when renaming files, as
you will see shortly. To load a plug-in,
select the plug-in from the list on the left,
and check the
Use this plugin
checkbox.
Then go on to click
Finish
.
templates, that is text strings with
control characters that tell the program
how to rename the files. You can click on
Functions
to view an explanation of the
wildcard characters (see Figure 4).
Entering a number sign
#
in the
Te m -
plate
text box tells the KRename to add a
serial number to the selected files. The
more number signs you add, the more
digits the serial number will have. The
program pads out the remaining digits
with zeros.
Be careful when renaming files: you
can not change the file extension by
default, as KRename will reapply the
original extension after renaming. There
is a workaround for this: simply uncheck
the
Use extension of the input file check-
box
. You can now add your new
template for the file extension in the
Template
text box.
Templates
This finally takes you to the screen
where you can rename your files in a
single batch process. KRename uses
Figure 4: Using wildcards to define a template for
renaming files.
Figure 5: KRename can add this characteristic of a
PNG file to the filename.
An Alternative Approach to
Plug-ins
After selecting a plug-in, you can select
Functions
in this dialog box to inspect
the functions provided by the plug-in.
KRename allows you to view the func-
tionality of any plug-in that you have
loaded. Figure 5 shows
PNG-Info
as an
example. You can select
[BitDepth]
, for
example, and then click on
Add
, KRe-
name will add the bit depth to the name
of any PNG image files you have selected
(see Figure 6).
■
GLOSSARY
Symbolic link:
If you need the same file at
two different locations in the filesystem tree
(where the files can have different names),
you do not need to create a copy. Instead, you
can enter the “ln -s” command at the desired
location to create a link to the file. If you
delete the original file later, the symbolic link
becomes orphaned.
Batch:
This is a term from the early days of
data processing where punch cards were used
to control commands running on computers.
Operators used to feed a “batch” of cards to
the card reader, which would process them
sequentially. Today, the term “batch” refers to
a collection of commands and functions
processed sequentially (and typically auto-
matically) by a program.
www.linux-magazine.com
August 2004
77
Plik z chomika:
Kapy97
Inne pliki z tego folderu:
2007.09_Health Check-Tools for Checking System Status.pdf
(646 KB)
2004.12_Hunters and Gatherers-Reading the News with Akregator.pdf
(4910 KB)
2004.11_Xml in Kde with Kxml Editor.pdf
(7389 KB)
2004.10_Kickpim-a Panel Applet for Quick Access to Your Address Book.pdf
(1903 KB)
2004.09_Context Menus-Using the Right Mouse Button to Greater Effect.pdf
(2362 KB)
Inne foldery tego chomika:
Beginners
Business News
Comment
Community
Community Notebook
Zgłoś jeśli
naruszono regulamin