Hello all, thanks for your time (and this forum, what an awesome resource for newbs like myself!)
Anyways, I've been given the task of importing content from a directory of about...7000 HTML files. They are all named appropriately and broken down by name depending on what book they belong too.
For example, say I have the book "my-book" the files are named:
Is there anyway I can just do a find/replace on the entire directory and specify the criteria? Thats the easiest way I could think of for now...doing something like.
FIND "-pagenumber-1." and REPLACE WITH "-pagenumber-001."
FIND "-pagenumber-2." and REPLACE WITH "-pagenumber-002."
FIND "-pagenumber-11." and REPLACE WITH "-pagenumber-011."
Is this possible out of the gates through a command in Terminal? Or maybe there's a script or program I could download to do this for me?
I really appreciate any of the help!
Code:
perl -wl -e 'foreach $file (glob "*.html"){
my $newfile=$file;
$newfile=~s/-([0-9])\./-00$1\./ and rename $file,$newfile and next;
$newfile=~s/-([0-9]{2})\./-0$1\./ and rename $file,$newfile;
}'
Hi all -
I'm trying to rename a large number of files all at once and need some help figuring out the command line syntax to do it. I've already done quite a bit of research with the rename and mv commands, but so far haven't found a solution that seems to work for me. So:
The files exist... (10 Replies)
hi all,
given a path, for example :
/<pwd>/artist/album/
what i would like to do is to rename the album directory like that :
/<pwd>/artist/artist | album/
and i would like to do the latter for all the "artist" directories
and for all the "album" directories that belong to an artist
... (4 Replies)
hi i have a folder full of files. some of the names are quite off because the dimensions were the same and i had to put a 'b' after the initial number so that it didnt overwrite. what i want is a script in unix to overwrite the filwe name leaving some of the title intact, e.g. below are some... (3 Replies)
Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below.
I am on a solaris server btw.
Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose.
... (2 Replies)
Hi all,
Wondering how this could be accomplished........
a directory contains sequentially numbered files from fw01 to fw999.
How would I insert an additional zero so that the directory lists these files in a proper manner?
(i.e. all double digit files from fw01 to fw99 would become... (3 Replies)
I have some 50+ files in the following format :
abcd_vish_running_ZEBRA_20140818.dat_08-14-2014_23:08:23
abcd_vish_running_ZEB-RA_20140818.dat_08-14-2014_23:08:35
abcd_vish_running_ZEB_RA_20140818.dat_08-14-2014_23:08:37
abcd_vish_running_RI-NG_20140818.dat_08-14-2014_23:08:42... (5 Replies)
Hi guys,
I need a script to change the file names e.g.:-
below are the mentioned files, i want t0 change the last character of the name 00000.cdr with e.g bep01.smsc.191214210500-00000.cdr to bep01.smsc.191214210500-92311.cdr next file be like bep01.smsc.191214210500-92312.cdr
# ls -ltr... (9 Replies)
I have a .ksh script that creates an sftp batch file and runs it through sftp. It works except for one thing. If I try to "put" to a different name, it doesn't use the specified remote name...it still "puts" the original local name.
I've tried both of these, and neither work...it will always... (4 Replies)
What is wrong with this script to rename batch of similar files? For example renaming all *.txt files to *.tab .
$ for i in seq {01..10}; do touch ${i}.txt; done
$ ./rename.sh *.txt txt tab
Error:
mv: ‘01.txt’ and ‘01.txt’ are the same file.
Code is:
#!/usr/bin/bash
# renames.sh
#... (6 Replies)
I wish to rename all files ending in .txt by removing .tex.
Currently I have
me@me-Inspiron-518:~$ ls
a.tex.txt bin b.tex.txt c.tex.txt Desktop Documents Downloads d.tex.txt Music Pictures Public Templates VideosDesired outcome
me@me-Inspiron-518:~$ ls
a.txt ... (2 Replies)
Discussion started by: Xubuntu56
2 Replies
LEARN ABOUT DEBIAN
marc::batch
MARC::Batch(3pm) User Contributed Perl Documentation MARC::Batch(3pm)NAME
MARC::Batch - Perl module for handling files of MARC::Record objects
SYNOPSIS
MARC::Batch hides all the file handling of files of "MARC::Record"s. "MARC::Record" still does the file I/O, but "MARC::Batch" handles the
multiple-file aspects.
use MARC::Batch;
# If you have werid control fields...
use MARC::Field;
MARC::Field->allow_controlfield_tags('FMT', 'LDX');
my $batch = MARC::Batch->new( 'USMARC', @files );
while ( my $marc = $batch->next ) {
print $marc->subfield(245,"a"), "
";
}
EXPORT
None. Everything is a class method.
METHODS
new( $type, @files )
Create a "MARC::Batch" object that will process @files.
$type must be either "USMARC" or "MicroLIF". If you want to specify "MARC::File::USMARC" or "MARC::File::MicroLIF", that's OK, too.
"new()" returns a new MARC::Batch object.
@files can be a list of filenames:
my $batch = MARC::Batch->new( 'USMARC', 'file1.marc', 'file2.marc' );
Your @files may also contain filehandles. So if you've got a large file that's gzipped you can open a pipe to gzip and pass it in:
my $fh = IO::File->new( 'gunzip -c marc.dat.gz |' );
my $batch = MARC::Batch->new( 'USMARC', $fh );
And you can mix and match if you really want to:
my $batch = MARC::Batch->new( 'USMARC', $fh, 'file1.marc' );
next()
Read the next record from that batch, and return it as a MARC::Record object. If the current file is at EOF, close it and open the next
one. "next()" will return "undef" when there is no more data to be read from any batch files.
By default, "next()" also will return "undef" if an error is encountered while reading from the batch. If not checked for this can cause
your iteration to terminate prematurely. To alter this behavior, see "strict_off()". You can retrieve warning messages using the
"warnings()" method.
Optionally you can pass in a filter function as a subroutine reference if you are only interested in particular fields from the record.
This can boost performance.
strict_off()
If you would like "MARC::Batch" to continue after it has encountered what it believes to be bad MARC data then use this method to turn
strict OFF. A call to "strict_off()" always returns true(1).
"strict_off()" can be handy when you don't care about the quality of your MARC data, and just want to plow through it. For safety,
"MARC::Batch" strict is ON by default.
strict_on()
The opposite of "strict_off()", and the default state. You shouldn't have to use this method unless you've previously used "strict_off()",
and want it back on again. When strict is ON calls to next() will return undef when an error is encountered while reading MARC data.
strict_on() always returns true(1).
warnings()
Returns a list of warnings that have accumulated while processing a particular batch file. As a side effect the warning buffer will be
cleared.
my @warnings = $batch->warnings();
This method is also used internally to set warnings, so you probably don't want to be passing in anything as this will set warnings on your
batch object.
"warnings()" will return the empty list when there are no warnings.
warnings_off()
Turns off the default behavior of printing warnings to STDERR. However, even with warnings off the messages can still be retrieved using
the warnings() method if you wish to check for them.
"warnings_off()" always returns true(1).
warnings_on()
Turns on warnings so that diagnostic information is printed to STDERR. This is on by default so you shouldn't have to use it unless you've
previously turned off warnings using warnings_off().
warnings_on() always returns true(1).
filename()
Returns the currently open filename or "undef" if there is not currently a file open on this batch object.
RELATED MODULES
MARC::Record, MARC::Lint
TODO
None yet. Send me your ideas and needs.
LICENSE
This code may be distributed under the same terms as Perl itself.
Please note that these modules are not products of or supported by the employers of the various contributors to the code.
AUTHOR
Andy Lester, "<andy@petdance.com>"
perl v5.10.1 2010-03-29 MARC::Batch(3pm)