Sponsored Content
Full Discussion: Multiple file renaming
Top Forums UNIX for Dummies Questions & Answers Multiple file renaming Post 302244423 by BigTool4u2 on Wednesday 8th of October 2008 02:42:18 AM
Old 10-08-2008
Multiple file renaming

Quote:
Originally Posted by ghostdog74
if you have Python, you can use the script here
example usage
Code:
# ls -1
IMAG0001.JPG
IMAG0002.JPG.ext2.ext2.ext2
IMAG0003.JPG.ext2.ext2.ext2
IMAG0005.JPG.ext2.ext2.ext2
IMAG0006.JPG.ext2.ext2.ext2

 ## filerenamer.py -s "IMAG(\d+)\.JPG.*" -e "CUBA01:99.JPG" -l -n "IMAG*" #remove -l to commit
==>>>>  [ /home/IMAG0001.JPG ]==>[ /home/CUBA01.JPG ]
==>>>>  [ /home/IMAG0002.JPG.ext2.ext2.ext2 ]==>[ /home/CUBA02.JPG ]
==>>>>  [ /home/IMAG0003.JPG.ext2.ext2.ext2 ]==>[ /home/CUBA03.JPG ]
==>>>>  [ /home/IMAG0005.JPG.ext2.ext2.ext2 ]==>[ /home/CUBA04.JPG ]
==>>>>  [ /home/IMAG0006.JPG.ext2.ext2.ext2 ]==>[ /home/CUBA05.JPG ]
 
# filerenamer.py -s "IMAG(\d+)\.JPG.*" -e "CUBA01:99.JPG"  -n "IMAG*"
/home/IMAG0001.JPG  is renamed to  /home/CUBA01.JPG
/home/IMAG0002.JPG.ext2.ext2.ext2  is renamed to  /home/CUBA02.JPG
/home/IMAG0003.JPG.ext2.ext2.ext2  is renamed to  /home/CUBA03.JPG
/home/IMAG0005.JPG.ext2.ext2.ext2  is renamed to  /home/CUBA04.JPG
/home/IMAG0006.JPG.ext2.ext2.ext2  is renamed to  /home/CUBA05.JPG


# ls -1
CUBA01.JPG
CUBA02.JPG
CUBA03.JPG
CUBA04.JPG
CUBA05.JPG

Thanks for your reply - I have python running on my system and it's the 1st time I've used it to be honest. Needless to say I do not know anything about it. The script that you've written, can it be used on any flavour of UNIX - I am using Mac OS X, I'm not sure if that has anything to do with the output which I'm getting of whether I do not know how to run the actual script.

I have tried t run it by copying the lines of code then pasting it in at the python prompt. When that happens I get the error

>>> [ /Users/johndoe/Desktop/Test/Picturefolder/IMAG0001.JPG ]==>[ /Users/johndoe/Desktop/Test/Picturefolder/CUBA01.JPG ]
File "<stdin>", line 1
[ /Users/johndoe/Desktop/Test/Picturefolder/IMAG0001.JPG ]==>[ /Users/johndoe/Desktop/Test/Picturefolder/CUBA01.JPG ]
^
SyntaxError: invalid syntax
>>>

What am I doing wrong here?

Thanks & Rgds.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Renaming multiple files

Can someone please tell me how I can rename a bunch of files at a time. I hava a directory that has 700+ files that are named *.xyz and I would like to rename them to *.abc . How can I do that with a simple command ? mv *.xyz *.abc did not work. Thanks in advance (4 Replies)
Discussion started by: jxh461
4 Replies

2. UNIX for Dummies Questions & Answers

Renaming of multiple filenames

Hi All, I need to rename the file names. I need to rename for example as follows file001 to flat1 file100 to flat100 Thanks Shash :confused: (7 Replies)
Discussion started by: shashi_kiran_v
7 Replies

3. UNIX for Dummies Questions & Answers

Renaming Multiple files

Hi All my dear friends I had multiple files in my directory with .pcv and .sqv extn I want to rename all .pcv files with .pc extn and all .sqv files with .sql extn Please help me out.:eek::mad::rolleyes: e.g. /trimsbld/users/dhirens/scripts/newfolder==>ll -rt total 2856 -rwxr-xr-x 1... (2 Replies)
Discussion started by: dhiren_shah
2 Replies

4. UNIX for Dummies Questions & Answers

Removing prefix from multiple files and renaming file extension

Hello i have the files in this format pdb1i0t.ent pdb1lv7.ent pdb1pp6.ent pdb1tj2.ent pdb1xg2.ent pdb2b4b.ent pdb2ewe.ent Now i have to remove the prefix pdb from all the files and also i need to change the extension of .ent to .txt The new file should look like this ... (3 Replies)
Discussion started by: empyrean
3 Replies

5. Shell Programming and Scripting

renaming multiple files

I have to rename 100+ files at a time on the server & was trying to use a script for doing that. I have used ultra edit to create a file having current filename & new file name as below file234.txt | file956.txt file687.txt | file385.txt There is no fixed pattern while renaming & would... (20 Replies)
Discussion started by: crux123
20 Replies

6. UNIX for Dummies Questions & Answers

Renaming multiple files

Hi, Can we rename multiples files using find or awk utility? Now I am doing it using for loop and getting the file name and in side the loop using the mv command. Like ine need t rename all txt files to doc file. For example a1.txt => a1.doc a2.txt => a2.doc a3.txt => a3.doc myfile.txt... (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

7. Shell Programming and Scripting

Renaming multiple files

I have 34 file in a directory that all have different names, however, they do have 1 pattern in commmon. They all have "-10-11-2010" date format in the name. I want to replace the date in the file name with a supplied date or maybe even the system date. I am sure I will be using awk or sed to... (9 Replies)
Discussion started by: Harleyrci
9 Replies

8. Shell Programming and Scripting

Renaming file that has multiple numbers as filename

Hi I have a file with filename as "partition-setup-and-ipl.vtcmd.76217657132.9721536798" Now i need to move this file as "partition-setup-and-ipl.vtcmd.76217657132.9721536798_org" i tried with # ls | grep -E "partition-setup-and-ipl.vtcmd.+"... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

9. Shell Programming and Scripting

Multiple File renaming with a twist

Hi I can do simple file renaming but this task is slightly more troublesome Ive got a guy that gives me multiple .pdf filles in a directory named something like 3412345.pdf 4565465.pdf 8534534.pdf And he also gives me a html file which is tabled with which shows the filenames above... (2 Replies)
Discussion started by: messiah1
2 Replies

10. Shell Programming and Scripting

Splitting file into multiple files and renaming them

Hi all, Newbie here. First of all, sorry if I made any mistakes while posting this question in terms of rules. Correct me if I am wrong. :b: I have a .dat file whose name is in the format of 20170311_abc_xyz.dat. The file consists of records whose first column consists of multiple dates in... (2 Replies)
Discussion started by: chanduris
2 Replies
MRENAME(1)						      General Commands Manual							MRENAME(1)

NAME
mrename - program to rename files SYNOPSIS
mrename 'pattern' prefix [option] DESCRIPTION
This manual page documents briefly the mrename command. This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. mrename is a tool for easy and automatic renaming of many files. The 'pattern' is the pattern to search files to rename (quoted to avoid that bash resolve it), and prefix is the prefix that will be added to the name of each file. The two alternative options for copying or moving files in the new name are explained below. All parameters are needed, and you have to stay and launch the script in the same direc- tory of the files to be renamed. The program should be able to write in this directory. OPTIONS
There are only the following three options. -c The option -c will copy each file with the new filename. -m The option -m will move each file in the new filename. -h Display help. EXAMPLE
If you have a directory with two jpeg images prof.jpg and forp.jpg and you want to add them a prefix like item0, item1 etc.. (that is item0prof.jpg, item1forp.jpg etc..) do this: cd /path/to/the/images mrename '*.jpg' item -c to copy each matching file into another with the new name mrename '*.jpg' item -m to rename each file without keeping a copy with the previous name Word-Wide-Web: http://alfalinux.sourceforge.net/mrename.php3 AUTHOR
: Giancarlo -rofus- Erra e-mail: rofus@mindless.com This manual page was written by Dr. Guenter Bechly <gbechly@debian.org>, for the Debian GNU/Linux system (but may be used by others). It is distributed under the GPL just like mrename itself. October 22, 2000 MRENAME(1)
All times are GMT -4. The time now is 09:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy