Sponsored Content
Full Discussion: Multiple file rename
Top Forums Shell Programming and Scripting Multiple file rename Post 302688337 by Lem on Saturday 18th of August 2012 06:31:35 PM
Old 08-18-2012
It's late for me now, but - with just GNU/Linux find and bash - you could start working from here:
Code:
find /tmp/fred{1..N}/bill{1..M}/tony/joe/file{02..12}.dat 2>/dev/null | while IFS= read -r filename; do num=${filename: -6:2}; newnum=$(echo "$num - 1" | bc); echo ${filename/%$num.dat/$newnum.new.dat} ; done

For instance:
Code:
lem@biggy:/tmp$ find /tmp/fred{1..2}/bill{1..4}/file{02..12}.dat 2>/dev/null
/tmp/fred1/bill3/file02.dat
/tmp/fred1/bill3/file03.dat
/tmp/fred1/bill3/file04.dat
/tmp/fred1/bill3/file05.dat
/tmp/fred1/bill3/file06.dat
/tmp/fred1/bill3/file07.dat
/tmp/fred1/bill3/file08.dat
/tmp/fred1/bill3/file09.dat
/tmp/fred1/bill3/file10.dat
/tmp/fred1/bill3/file11.dat
/tmp/fred1/bill3/file12.dat
/tmp/fred2/bill4/file02.dat
/tmp/fred2/bill4/file03.dat
/tmp/fred2/bill4/file04.dat
/tmp/fred2/bill4/file05.dat
/tmp/fred2/bill4/file06.dat
/tmp/fred2/bill4/file07.dat
/tmp/fred2/bill4/file08.dat
/tmp/fred2/bill4/file09.dat
/tmp/fred2/bill4/file10.dat
/tmp/fred2/bill4/file11.dat
/tmp/fred2/bill4/file12.dat
lem@biggy:/tmp$ find /tmp/fred{1..2}/bill{1..4}/file{02..12}.dat 2>/dev/null | while IFS= read -r filename; do num=${filename: -6:2}; newnum=$(echo "$num - 01" | bc); echo ${filename/%$num.dat/$newnum.new.dat} ; done
/tmp/fred1/bill3/file1.new.dat
/tmp/fred1/bill3/file2.new.dat
/tmp/fred1/bill3/file3.new.dat
/tmp/fred1/bill3/file4.new.dat
/tmp/fred1/bill3/file5.new.dat
/tmp/fred1/bill3/file6.new.dat
/tmp/fred1/bill3/file7.new.dat
/tmp/fred1/bill3/file8.new.dat
/tmp/fred1/bill3/file9.new.dat
/tmp/fred1/bill3/file10.new.dat
/tmp/fred1/bill3/file11.new.dat
/tmp/fred2/bill4/file1.new.dat
/tmp/fred2/bill4/file2.new.dat
/tmp/fred2/bill4/file3.new.dat
/tmp/fred2/bill4/file4.new.dat
/tmp/fred2/bill4/file5.new.dat
/tmp/fred2/bill4/file6.new.dat
/tmp/fred2/bill4/file7.new.dat
/tmp/fred2/bill4/file8.new.dat
/tmp/fred2/bill4/file9.new.dat
/tmp/fred2/bill4/file10.new.dat
/tmp/fred2/bill4/file11.new.dat

HTH.
--
Bye
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with multiple file rename - change case of part of file name

Hi there, I hope someone can help me with this problem : I have a directory (/var/www/file/imgprofil) which contains about 10000 JPG files. They have a naming convention thus : prefix-date-key-suffix.jpg they all have the prefix p-20050608- then AAAA is a 4 letter code the suffix is... (7 Replies)
Discussion started by: steve7
7 Replies

2. Shell Programming and Scripting

mv command to rename multiple files that retain some portion of the original file nam

Well the title is not too good, so I will explain. I need to move (rename) files using a simple AIX script. ???file1.txt ???file2.txt ???file1a.txt ???file2a.txt to be: ???renamedfile1'date'.txt ???renamedfile2'date'.txt ???renamedfile1a'date'.txt ???renamedfile2a'date'.txt ... (4 Replies)
Discussion started by: grimace15
4 Replies

3. Shell Programming and Scripting

Rename multiple file from file listing

I am new at Linux/UNIX programming. Here is my problem. I had one big file which I split using the command csplit -k -s -f april.split. april '/^ISA/' '{10000}' So now I have multiple files with names april.split.01 april.split.02 april.split.03 But I need the name of the file like... (5 Replies)
Discussion started by: yshahiac
5 Replies

4. Shell Programming and Scripting

Multiple file rename (change in filename in unix with single command

Dear All, Please help ! i ham having 300 file with E.G. PMC1_4567.arc in seq. like PMC1_4568.arc,PMC1_4569.arc ...n and so on.. i want all those file to be rename like PMC_4567.arc ,PMC_4568.arc .. mean i want to remove 1 from first file name .. pls help.. (6 Replies)
Discussion started by: moon_22
6 Replies

5. UNIX for Dummies Questions & Answers

For Loop To Rename Multiple Files Finds One Non-existant File

Okay so here's something that's confusing me: I have a script that's designed to remove the words "new_" from the front of any file except two exceptions and it looks something like this... for i in new_* do if ] && ]; then j=`echo "$i"|cut -c5-` mv $i $j fi done ... (5 Replies)
Discussion started by: Korn0474
5 Replies

6. Shell Programming and Scripting

Rename multiple file names in a directory

I hope some one can help me I have multiple files in a directory with out extension like as below mentioned. But i want to change all the file names along .DDMMYYYYHHMISS format. And all files should have same DDMMYYYYHHMISS. Scenario: direcory name = /vol/best/srcfiles files in a... (4 Replies)
Discussion started by: hari001
4 Replies

7. UNIX for Dummies Questions & Answers

Multiple file rename

hi im new to linux and was just wondering if some 1 could help me i have folders with T.V. series in them and i would like to delete part of the filename e.g. (series name).s01e01.(episode name) (series name).s01e02.(episode name) (series name).s01e03.(episode name) (series... (4 Replies)
Discussion started by: stevemcd1990
4 Replies

8. Shell Programming and Scripting

Multiple File Rename based on pattern - one line

All, I wanted to copy the files From: Daily_XYZ_TEST_1.csv Daily_XYZ_TEST_2.csv Daily_XYZ_TEST_3.csv Daily_XYZ_TEST_4.csv To: Daily_ABC_TEST_1.csv Daily_ABC_TEST_2.csv Daily_ABC_TEST_3.csv Daily_ABC_TEST_4.csv I have tried the rename command but it is not working (5 Replies)
Discussion started by: alfredo123
5 Replies

9. UNIX for Dummies Questions & Answers

Rename Multiple Files

Hey guys, I am the definition of a newbie. I am in the process of trying to rip all my dvds onto a new HTPC I setup. While doing this, I am also trying to organize a bunch of other files I already have to proper naming conventions. So far I have just been naming each file separately (I am on a... (4 Replies)
Discussion started by: Ralze34
4 Replies

10. Shell Programming and Scripting

How to rename multiple file names?

Hi all, I need to rename more file name in one command or script. The files have this structure: XxY - filename.doc where X and Y are numbers and the x is the letter itself. I need to rename these files with this structure: string.S0XEY.filename.doc the string is a suffix that... (8 Replies)
Discussion started by: idro
8 Replies
SDPA(1) 						      General Commands Manual							   SDPA(1)

NAME
SDPA - High-performance software package for SemiDefinite Programs SYNOPSIS
sdpa DataFile OutputFile [InitialPtFile] [-pt parameters] [-dimacs] [-numThreads numThreads] sdpa [options] files... sdpa --version DESCRIPTION
sdpa - "SDPA (SemiDefinite Programming Algorithm)" is one of the most efficient and stable software packages for solving SDPs based on the primal-dual interior-point method. SDP (SemiDefinite Program) is used for financial engineering, machine learning, control theory, sensor network problem, quantum chemistry, quantum information, combinatorial optimizaiton, polynomial optimization, and so on. Futher information on SDP and SDPA can be found at http://sdpa.sourceforge.net/ OPTIONS
---- option type 1 ---- sdpa DataFile OutputFile [InitialPtFile] [-pt parameters] [-dimacs] [-numThreads numThreads] parameters = 0 default, 1 fast (unstable), 2 slow (stable) example1-1: sdpa example1.dat example1.result example1-2: sdpa example1.dat-s example1.result example1-3: sdpa example1.dat example1.result example1.ini example1-4: sdpa example1.dat example1.result -pt 2 example1-5: sdpa example1.dat example1.result -dimacs example1-6: sdpa example1.dat example1.result -numThreads 4 ---- option type 2 ---- sdpa [option filename]+ -dd : data dense :: -ds : data sparse -id : init dense :: -is : init sparse -o : output :: -p : parameter -pt : parameters , 0 default, 1 fast (unstable) 2 slow (stable) example2-1: sdpa -o example1.result -dd example1.dat example2-2: sdpa -ds example1.dat-s -o example1.result -p param.sdpa example2-3: sdpa -ds example1.dat-s -o example1.result -pt 2 example2-4: sdpa -ds example1.dat-s -o example1.result -dimacs example2-5: sdpa -ds example1.dat-s -o example1.result -numThreads 4 ---- option type 3 ---- sdpa --version to print out version and exit. PARAMETER_FILE is decided by the following priority 1: The file assigned by '-p' option of 'option type 2'. For 'option type1', this is skipped. 2: ./param.sdpa For 'option type2', this is skipped. 3: /usr/share/sdpa/param.sdpa 4: Default parameter -dimacs printout dimacs information incurring additional computation cost -numThreads number of pthreads for internal computation AUTHOR
SDPA was written by SDPA Project <sdpa-developers@lists.sourceforge.net>. This manual page was written by Makoto Yamashita <Makoto.Yamashita@is.titech.ac.jp>. July 28, 2011 SDPA(1)
All times are GMT -4. The time now is 12:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy