Sponsored Content
Top Forums Shell Programming and Scripting Need help for a Shell script to rename multiple files Post 302400587 by kidney514 on Wednesday 3rd of March 2010 04:07:28 PM
Old 03-03-2010
Need help for a Shell script to rename multiple files

Hi!

I need help to create a shell script to search inside a file and then copy a portion of the search result as the new file name.

Basically I was hacked over the weekend and the genius wipe out my drive from my server. I was able to recover alot of files, but biggest problem Is now the files have no name and make it impossible to sort.

I have found the filename inside the files themself and need to search for it and then rename the file with the results.
Approx 12 000 files to be done.

Here is a sample of the source of the files I'm talking about:
Code:
%!PS-Adobe-3.1 EPSF-3.0
%ADO_DSC_Encoding: MacOS Roman
%%Title: carte_finale_GestionPhocusout.eps
%%Creator: Adobe Illustrator(R) 14.0
%%For: Porky
%%CreationDate: 09-11-09
%%BoundingBox: 0 0 360 489
%%HiResBoundingBox: 0 0 359.9981 488.5669
%%CropBox: 0 0 359.9981 488.5669
%%LanguageLevel: 3

This is the filename inside the file itself right after the "%%Title: "
Code:
%%Title: carte_finale_GestionPhocusout.eps

Now with this info, I want to rename the file itself to exactly this:
Code:
carte_finale_GestionPhocusout.eps

Can it be done?

Many thanks for taking the time to read and help me with this!

Last edited by Scott; 03-03-2010 at 06:14 PM.. Reason: Code tags please...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

rename multiple files

Hi, can anyone have a ksh script to rename multiple files (ie to remove .Z extension of the files) can someone correct this? for i in *.Z do var1 = substr($i, 1,at(".Z",$i)-1) mv $i $var1 done Thanks.. Antony (13 Replies)
Discussion started by: antointoronto
13 Replies

2. Shell Programming and Scripting

Shell script to rename files with .1,.2,.3 ....ext respectively

Hey Guys.... Just need some help as I am not proficient in Unix shell script... Doubt: --------------- Suppose there will be some of the following files inside a directory called OUT ... Path: - /appdb1/product/batch/rms/OUT files inside OUT directory:- POSU_75002_20090127_20090129035442... (4 Replies)
Discussion started by: satyajit007
4 Replies

3. Shell Programming and Scripting

Shell Script to rename files

Hi, i need a bit of help writting a tcsh script which renames all ascii text files in the current directory by adding a number to their names before the extension so for example, a directory containing the files Hello.txt Hello.t Hello should have the following changes, Hello.txt... (2 Replies)
Discussion started by: yakuzaa
2 Replies

4. Shell Programming and Scripting

Shell script to rename a group of files

Hello, I am having 1800 files in a directory with a specified format, like amms_850o_prod.000003uNy amms_850o_prod.000003u8x amms_850o_prod.000003taP amms_850o_prod.000003tKy amms_850o_prod.000003si4 amms_850o_prod.000003sTP amms_850o_prod.000003sBg amms_850o_prod.000003rvx... (12 Replies)
Discussion started by: atlantis
12 Replies

5. Shell Programming and Scripting

Rename the multiple files

Hi I need to reanme the multiple file using unix script I have multiple file like: sample_YYYYMMDD.xls test new_YYYYMMDD.xls simple_YYYYMMDD.xls I need to rename this file sample.xls testnew.xls SIMPLE.xls thanks (8 Replies)
Discussion started by: murari83.ds
8 Replies

6. Shell Programming and Scripting

Rename multiple files

hello: I have multiple files with names like: somestring_y2010m01d01 somestring_y2010m01d02 .......... somestring_y2010m12d31 How... (4 Replies)
Discussion started by: sylcam
4 Replies

7. Shell Programming and Scripting

Rename multiple files

Hi, In my directory I have many files, for e.g. file_123 file_124 file_125 file_126 file_127 Instead of renaming these files one by one, I would like to rename them at a same time using same command... they should appear like 123 124 125 126 127 What command(awk or ls or... (3 Replies)
Discussion started by: juzz4fun
3 Replies

8. UNIX for Dummies Questions & Answers

Rename multiple files in shell bash, changing elements order.

Hi, I want to rename several files like this: example: A0805120817.BHN A0805120818.BHN ..... to: 20120817.0805.N 20120818.0805.N ...... How can i do this via terminal or in shell bash script ? thanks, (6 Replies)
Discussion started by: pintolcv
6 Replies

9. Shell Programming and Scripting

SBATCH trinity for multiple files and rename/move the output files

Hey guys, I have wrote the following script to apply a module named "trinity" on my files. (it takes two input files and spit a trinity.fasta as output) #!/bin/bash -l #SBATCH -p node #SBATCH -A <projectID> #SBATCH -n 16 #SBATCH -t 7-00:00:00 #SBATCH --mem=128GB #SBATCH --mail-type=ALL... (1 Reply)
Discussion started by: @man
1 Replies

10. Shell Programming and Scripting

Oop to copy and rename files through SQL Statement in shell Script

#!/bin/sh sqlplus -s "/ as sysdba" << EOF SET HEADING OFF SET FEEDBACK OFF Select pt.user_concurrent_program_name , OUTFILE_NAME FROm apps.fnd_concurrent_programs_tl pt, apps.fnd_concurrent_requests f where pt.concurrent_program_id = f.concurrent_program_id and pt.application_id =... (1 Reply)
Discussion started by: usman_oracle
1 Replies
PostScript::Simple::EPS(3)				User Contributed Perl Documentation				PostScript::Simple::EPS(3)

NAME
PostScript::Simple::EPS - EPS support for PostScript::Simple SYNOPSIS
use PostScript::Simple; # create a new PostScript object $p = new PostScript::Simple(papersize => "A4", colour => 1, units => "in"); # create a new page $p->newpage; # add an eps file $p->add_eps({xsize => 3}, "test.eps", 1,1); $p->add_eps({yscale => 1.1, xscale => 1.8}, "test.eps", 4,8); # create an eps object $e = new PostScript::Simple::EPS(file => "test.eps"); $e->rotate(90); $e->xscale(0.5); $p->add_eps($e, 3, 3); # add eps object to postscript object $e->xscale(2); $p->add_eps($e, 2, 5); # add eps object to postscript object again # write the output to a file $p->output("file.ps"); DESCRIPTION
PostScript::Simple::EPS allows you to add EPS files into PostScript::Simple objects. Included EPS files can be scaled and rotated, and placed anywhere inside a PostScript::Simple page. Remember when using translate/scale/rotate that you will normally need to do the operations in the reverse order to that which you expect. PREREQUISITES
This module requires "PostScript::Simple", "strict", "Carp" and "Exporter". EXPORT None. CONSTRUCTOR
"new(options)" Create a new PostScript::Simple::EPS object. The options that can be set are: file EPS file to be included. This or "source" must exist when the "new" method is called. source PostScript code for the EPS document. Either this or "file" must be set when "new" is called. clip Set to 0 to disable clipping to the EPS bounding box. Default is to clip. Example: $ps = new PostScript::Simple(landscape => 1, eps => 0, xsize => 4, ysize => 3, units => "in"); $eps = new PostScript::Simple::EPS(file => "test.eps"); $eps->scale(0.5); Scale the EPS file by x0.5 in both directions. $ps->newpage(); $ps->importeps($eps, 1, 1); Add the EPS file to the PostScript document at coords (1,1). $ps->importepsfile("another.eps", 1, 2, 4, 4); Easily add an EPS file to the PostScript document using bounding box (1,2),(4,4). The methods "importeps" and "importepsfile" are described in the documentation of "PostScript::Simple". OBJECT METHODS
All object methods return 1 for success or 0 in some error condition (e.g. insufficient arguments). Error message text is also drawn on the page. "get_bbox" Returns the EPS bounding box, as specified on the %%BoundingBox line of the EPS file. Units are standard PostScript points. Example: ($x1, $y1, $x2, $y2) = $eps->get_bbox(); "width" Returns the EPS width. Example: print "EPS width is " . abs($eps->width()) . " "; "height" Returns the EPS height. Example: To scale $eps to 72 points high, do: $eps->scale(1, 72/$eps->height()); "scale(x, y)" Scales the EPS file. To scale in one direction only, specify 1 as the other scale. To scale the EPS file the same in both directions, you may use the shortcut of just specifying the one value. Example: $eps->scale(1.2, 0.8); # make wider and shorter $eps->scale(0.5); # shrink to half size "rotate(deg)" Rotates the EPS file by "deg" degrees anti-clockwise. The EPS file is rotated about it's own origin (as defined by it's bounding box). To rotate by a particular co-ordinate (again, relative to the EPS file, not the main PostScript document), use translate, too. Example: $eps->rotate(180); # turn upside-down To rotate 30 degrees about point (50,50): $eps->translate(50, 50); $eps->rotate(30); $eps->translate(-50, -50); "translate(x, y)" Move the EPS file by "x","y" PostScript points. Example: $eps->translate(10, 10); # move 10 points in both directions "reset" Clear all translate, rotate and scale operations. Example: $eps->reset(); "load" Reads the EPS file into memory, to save reading it from file each time if inserted many times into a document. Can not be used with "preload". "preload(object)" Experimental: defines the EPS at in the document prolog, and just runs a command to insert it each time it is used. "object" is a PostScript::Simple object. If the EPS file is included more than once in the PostScript file then this will probably shrink the filesize quite a lot. Can not be used at the same time as "load", or when using EPS objects defined from PostScript source. Example: $p = new PostScript::Simple(); $e = new PostScript::Simple::EPS(file => "test.eps"); $e->preload($p); BUGS
This is software in development; some current functionality may not be as expected, and/or may not work correctly. AUTHOR
The PostScript::Simple::EPS module was written by Matthew Newton, after prods for such a feature from several people around the world. A useful importeps function that provides scaling and aspect ratio operations was gratefully received from Glen Harris, and merged into this module. Copyright (C) 2002-2003 Matthew C. Newton / Newton Computing This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details, available at http://www.gnu.org/licenses/gpl.html. SEE ALSO
PostScript::Simple perl v5.12.1 2005-03-03 PostScript::Simple::EPS(3)
All times are GMT -4. The time now is 03:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy