Sponsored Content
Top Forums Shell Programming and Scripting script for renaming a batch of files Post 302443041 by shabs1985 on Friday 6th of August 2010 11:09:27 AM
Old 08-06-2010
Question script for renaming a batch of files

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 filenames..
obj2-68x130x114.bin
obj1-46x48x39.bin
obj1b-25x33x39.bin
obj1-35x36x23.bin
what i would like is the file names to be rewritten leaving the bold part intact and the italics part to go down in chronological order from obj1 to objx, x being the final value in the series. it doesnt have to be by the modified date as this doesnt mater. i just need distinguishable filenames. thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Batch Renaming: Change files' extensions in many sub-directories

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)
Discussion started by: dave920
10 Replies

2. Shell Programming and Scripting

batch renaming ...

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)
Discussion started by: OneDreamCloser
4 Replies

3. UNIX for Dummies Questions & Answers

Batch Renaming of Files

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.... (8 Replies)
Discussion started by: gratefulhokie
8 Replies

4. Shell Programming and Scripting

Executing a batch of files within a shell script with option to refire the individual files in batch

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)
Discussion started by: goddevil
2 Replies

5. Shell Programming and Scripting

BASH Batch renaming insert additional zero into filename

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)
Discussion started by: putter1900
3 Replies

6. Shell Programming and Scripting

Need to exclude .NFSxxx files in clear old files batch script

I am new to Shell Scripting and need some help. The following batch job has been failing for me due to the .nfsxxx files in use. I need to know how to modify the following script to exclude the .nfsxxx files so this batch job will not fail on me. I have done lots of googling and keep coming back... (2 Replies)
Discussion started by: kimberlyg2007
2 Replies

7. Shell Programming and Scripting

Need help in batch renaming files with bash shell script.

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)
Discussion started by: SriRamKrish
5 Replies

8. Shell Programming and Scripting

Renaming file in batch

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)
Discussion started by: mfaizan40
9 Replies

9. Shell Programming and Scripting

Script for batch renaming

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)
Discussion started by: yifangt
6 Replies

10. UNIX for Beginners Questions & Answers

Renaming batch by removing substring

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
Math::BigInt::Calc(3pm) 				 Perl Programmers Reference Guide				   Math::BigInt::Calc(3pm)

NAME
Math::BigInt::Calc - Pure Perl module to support Math::BigInt SYNOPSIS
Provides support for big integer calculations. Not intended to be used by other modules. Other modules which sport the same functions can also be used to support Math::BigInt, like Math::BigInt::GMP or Math::BigInt::Pari. DESCRIPTION
In order to allow for multiple big integer libraries, Math::BigInt was rewritten to use library modules for core math routines. Any module which follows the same API as this can be used instead by using the following: use Math::BigInt lib => 'libname'; 'libname' is either the long name ('Math::BigInt::Pari'), or only the short version like 'Pari'. STORAGE
METHODS
The following functions MUST be defined in order to support the use by Math::BigInt v1.70 or later: api_version() return API version, 1 for v1.70, 2 for v1.83 _new(string) return ref to new object from ref to decimal string _zero() return a new object with value 0 _one() return a new object with value 1 _two() return a new object with value 2 _ten() return a new object with value 10 _str(obj) return ref to a string representing the object _num(obj) returns a Perl integer/floating point number NOTE: because of Perl numeric notation defaults, the _num'ified obj may lose accuracy due to machine-dependent floating point size limitations _add(obj,obj) Simple addition of two objects _mul(obj,obj) Multiplication of two objects _div(obj,obj) Division of the 1st object by the 2nd In list context, returns (result,remainder). NOTE: this is integer math, so no fractional part will be returned. The second operand will be not be 0, so no need to check for that. _sub(obj,obj) Simple subtraction of 1 object from another a third, optional parameter indicates that the params are swapped. In this case, the first param needs to be preserved, while you can destroy the second. sub (x,y,1) => return x - y and keep x intact! _dec(obj) decrement object by one (input is guaranteed to be > 0) _inc(obj) increment object by one _acmp(obj,obj) <=> operator for objects (return -1, 0 or 1) _len(obj) returns count of the decimal digits of the object _digit(obj,n) returns the n'th decimal digit of object _is_one(obj) return true if argument is 1 _is_two(obj) return true if argument is 2 _is_ten(obj) return true if argument is 10 _is_zero(obj) return true if argument is 0 _is_even(obj) return true if argument is even (0,2,4,6..) _is_odd(obj) return true if argument is odd (1,3,5,7..) _copy return a ref to a true copy of the object _check(obj) check whether internal representation is still intact return 0 for ok, otherwise error message as string _from_hex(str) return new object from a hexadecimal string _from_bin(str) return new object from a binary string _from_oct(str) return new object from an octal string _as_hex(str) return string containing the value as unsigned hex string, with the '0x' prepended. Leading zeros must be stripped. _as_bin(str) Like as_hex, only as binary string containing only zeros and ones. Leading zeros must be stripped and a '0b' must be prepended. _rsft(obj,N,B) shift object in base B by N 'digits' right _lsft(obj,N,B) shift object in base B by N 'digits' left _xor(obj1,obj2) XOR (bit-wise) object 1 with object 2 Note: XOR, AND and OR pad with zeros if size mismatches _and(obj1,obj2) AND (bit-wise) object 1 with object 2 _or(obj1,obj2) OR (bit-wise) object 1 with object 2 _mod(obj1,obj2) Return remainder of div of the 1st by the 2nd object _sqrt(obj) return the square root of object (truncated to int) _root(obj) return the n'th (n >= 3) root of obj (truncated to int) _fac(obj) return factorial of object 1 (1*2*3*4..) _pow(obj1,obj2) return object 1 to the power of object 2 return undef for NaN _zeros(obj) return number of trailing decimal zeros _modinv return inverse modulus _modpow return modulus of power ($x ** $y) % $z _log_int(X,N) calculate integer log() of X in base N X >= 0, N >= 0 (return undef for NaN) returns (RESULT, EXACT) where EXACT is: 1 : result is exactly RESULT 0 : result was truncated to RESULT undef : unknown whether result is exactly RESULT _gcd(obj,obj) return Greatest Common Divisor of two objects The following functions are REQUIRED for an api_version of 2 or greater: _1ex($x) create the number 1Ex where x >= 0 _alen(obj) returns approximate count of the decimal digits of the object. This estimate MUST always be greater or equal to what _len() returns. _nok(n,k) calculate n over k (binomial coefficient) The following functions are optional, and can be defined if the underlying lib has a fast way to do them. If undefined, Math::BigInt will use pure Perl (hence slow) fallback routines to emulate these: _signed_or _signed_and _signed_xor Input strings come in as unsigned but with prefix (i.e. as '123', '0xabc' or '0b1101'). So the library needs only to deal with unsigned big integers. Testing of input parameter validity is done by the caller, so you need not worry about underflow (f.i. in "_sub()", "_dec()") nor about division by zero or similar cases. The first parameter can be modified, that includes the possibility that you return a reference to a completely different object instead. Although keeping the reference and just changing its contents is preferred over creating and returning a different reference. Return values are always references to objects, strings, or true/false for comparison routines. WRAP YOUR OWN
If you want to port your own favourite c-lib for big numbers to the Math::BigInt interface, you can take any of the already existing modules as a rough guideline. You should really wrap up the latest BigInt and BigFloat testsuites with your module, and replace in them any of the following: use Math::BigInt; by this: use Math::BigInt lib => 'yourlib'; This way you ensure that your library really works 100% within Math::BigInt. LICENSE
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. AUTHORS
Original math code by Mark Biggar, rewritten by Tels <http://bloodgate.com/> in late 2000. Seperated from BigInt and shaped API with the help of John Peacock. Fixed, speed-up, streamlined and enhanced by Tels 2001 - 2007. SEE ALSO
Math::BigInt, Math::BigFloat, Math::BigInt::GMP, Math::BigInt::FastCalc and Math::BigInt::Pari. perl v5.12.1 2010-04-26 Math::BigInt::Calc(3pm)
All times are GMT -4. The time now is 01:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy