Sponsored Content
Full Discussion: Rename Filenames
Top Forums Shell Programming and Scripting Rename Filenames Post 302926052 by ali.seifaddini on Thursday 20th of November 2014 10:42:03 PM
Old 11-20-2014
Quote:
Originally Posted by Chubler_XL
Try this script:

Code:
for file in SG1*.CAP*
do
   new=${file#SG1}
   new=${new%.CAP*}
   if [ -f "$new" ]
   then
       echo "Not renaming $file as $new already exists!" >&2
   else
       echo mv "$file" "$new"
   fi
done

remove echo - when you happy with what it will do.


EDIT: too late, damn you junior-helper!! LOL

Hello

I run the script, but noting happened !!!

---------- Post updated at 07:12 AM ---------- Previous update was at 07:11 AM ----------

Quote:
Originally Posted by junior-helper
Try
Code:
for file in SG1*.CAP*; do
 new=${file#SG1}
 new=${new%.CAP*}
 echo mv "$file" "$new"
done

If the output is as expected, remove echo to rename the files.

Hi

Not working!!!!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

spaces in filenames

I have a problem with the script below #!/bin/sh for vo in `find -maxdepth 1 -type f -regex "^\./*$"` do ls -l "$vo" some other commands done It works fine until `find ...` returns files with spaces. I've tryed to change IFS but haven't succeed Any solutions? (4 Replies)
Discussion started by: Hitori
4 Replies

2. UNIX for Dummies Questions & Answers

How can I rename multiple files depending on a string occuring in the filenames?

I have many files that have "inputstring" somewhere in their filename (without the quotes), and I want to rename them all so that "inputstring" is replaced with "newstring". And I also want to specify arbitrary text for "inputstring" and "newstring" so that I can call the scripts that does this... (6 Replies)
Discussion started by: karman
6 Replies

3. Shell Programming and Scripting

Patterns in Filenames

Hi, To start, I am using a bash shell on a G4 powerbook running Leopard. I am attempting to write a shell script that will automate the processing of satellite imagery. All the filenames are of the following construction: A2008196000500.L2 where A indicates the sensor, the next four... (6 Replies)
Discussion started by: msb65
6 Replies

4. UNIX for Dummies Questions & Answers

parsing filenames

How can I loose a part of the filename I want to drop the “_<Number>.sql” Below I have a listing of file names in a file Eg : CREDIT_DEL_033333.sql I want it to be CREDIT_DEL ATM_DEBIT_CARD_0999999.sql I want it to be ... (3 Replies)
Discussion started by: jville
3 Replies

5. Shell Programming and Scripting

Extracting filenames

Hi I need to pull out the name of the file from the path. See, here is my loop that gets the files: dsxdir="/var/local/dsx/import" for dsxfile in $dsxdir/*.dsx; do dsxlog $reverb --info --module="$module" "$dsxfile" $dsximp $norule $oprange --dsn=$dsn --dbname=$dbname... (6 Replies)
Discussion started by: ladyAnne
6 Replies

6. UNIX for Dummies Questions & Answers

renaming filenames

I have 7 files with 7 different names coming into a specified folder on weekly basis, i need to pick a file one after another and load into oracle table using sql loader. I am using ksh to do this. So in the process if the file has error records and if sql loader fails to load into oracle tables,... (0 Replies)
Discussion started by: vpv0002
0 Replies

7. Shell Programming and Scripting

Manipulating Filenames

Hi Folks, I'm looking for some ideas on how to change some file names. I'm pretty sure I need to use sed or awk but they still escape me. The files I have are like: VOD0615 NEW Blades R77307.pdf or VOD0615_NEW_Blades_R77307.pdf and what I want after processing is: R77307 NEW Blades.pdf ... (5 Replies)
Discussion started by: imonkey
5 Replies

8. AIX

filemon with no filenames...

i excuted filemon with filemon -u -o /tmp/filemon.out -O all;sleep 60; trcstop. everything is ok, but i only get PID for filenames in Most Active Files. is there any different flags i need to use to get filenames? Code tags please, thanks. (3 Replies)
Discussion started by: curtis911
3 Replies

9. Shell Programming and Scripting

get filenames from log

Hi. I'm trying to get the names of files from a log file, without the path and special characters. I have a file that contains lines like this: '/path/to/files/file00010000070874.EXT' '/path/to/files/file00010000070875.EXT' '/path/to/files/file00010000070876.EXT'... (4 Replies)
Discussion started by: Hekm
4 Replies

10. Slackware

cp does not like filenames with accents?

Hi: mkisofs -graft-points -rational-rock -joliet -joliet-long -full-iso9660-filenames -iso-level 2 -o /tmp/image.iso STORE1/=/almacen/strauss In /almacen/strauss there are filenames containing not only spaces but accented characters as well. I burned the image to DVD, with the result that all... (2 Replies)
Discussion started by: stf92
2 Replies
Business::EDI::Spec(3pm)				User Contributed Perl Documentation				  Business::EDI::Spec(3pm)

NAME
Business::EDI::Spec - Object class for CSV-based U.N. EDI specifications SYNOPSIS
use Business::EDI::Spec; my $spec = Business::EDI::Spec->new('segment'); DESCRIPTION
CSV files originally from edi4r are included as part of Business::EDI. They are used to define the many different messages, segements, data elements, composite data elements, and codelists that are part of a given version of the U.N. specification. The CSV spec files are composed differently for the different structures defined. So we have to parse them differently. ==> Business/EDI/data/edifact/untdid/EDCD.d07a.csv # Composite Elements CompositeCode;label;pos;code;mandatory;def;[pos;code;mandatory;def;...] C001;TRANSPORT MEANS;010;8179;C;an..8;020;1131;C;an..17;030;3055;C;an..3;040;8178;C;an..17; C002;DOCUMENT/MESSAGE NAME;010;1001;C;an..3;020;1131;C;an..17;030;3055;C;an..3;040;1000;C;an..35; C004;EVENT CATEGORY;010;9637;C;an..3;020;1131;C;an..17;030;3055;C;an..3;040;9636;C;an..70; C001 => {label => 'TRANSPORT MEANS;010;8179;C;an..8;020;1131;C;an..17;030;3055;C;an..3;040;8178;C;an..17; ==> Business/EDI/data/edifact/untdid/EDED.d07a.csv # Data Elements code;def;class(?):label 1000;an..35;B;Document name 1001;an..3;C;Document name code 1003;an..6;B;Message type code 1000 => {label => 'an..35;B;Document name ==> Business/EDI/data/edifact/untdid/EDMD.d07a.csv # Messages MessageCode:x:rel:org:z:SegmentGroup;label;SegCode;mandatory;repeats;[SegCode;mandatory;repeats;...] APERAK:D:07A:UN::;Application error and acknowledgement message;UNH;M;1;BGM;M;1;DTM;C;9;FTX;C;9;CNT;C;9;SG1;C;99;SG2;C;9;SG3;C;9;SG4;C;99999;UNT;M;1 APERAK:D:07A:UN::SG1;SG01;DOC;M;1;DTM;C;99 APERAK:D:07A:UN::SG2;SG02;RFF;M;1;DTM;C;9 APERAK:D:07A:UN:: => {label => 'Application error and acknowledgement message', UNH;M;1; BGM;M;1; DTM;C;9;FTX;C;9;CNT;C;9;SG1;C;99;SG2;C;9;SG3;C;9;SG4;C;99999;UNT;M;1 ==> Business/EDI/data/edifact/untdid/EDSD.d07a.csv # Segments SegCode;label;pos;code;class;repeats[pos;code;class;repeats;...] ADR;ADDRESS;010;C817;C;1;020;C090;C;1;030;3164;C;1;040;3251;C;1;050;3207;C;1;060;C819;C;5;070;C517;C;5; AGR;AGREEMENT IDENTIFICATION;010;C543;C;1;020;9419;C;1; AJT;ADJUSTMENT DETAILS;010;4465;M;1;020;1082;C;1; ADR => {label => 'ADDRESS', 010;C817;C;1;020;C090;C;1;030;3164;C;1;040;3251;C;1;050;3207;C;1;060;C819;C;5;070;C517;C;5; ==> Business/EDI/data/edifact/untdid/IDCD.d07a.csv # Composites (interactive) E001 => {label => 'ADDRESS DETAILS;010;3477;M;an..3;020;3286;M;an..70;030;3286;C;an..70;040;3286;C;an..70;050;3286;C;an..70;060;3286;C;an..70;070;3286;C;an..70; ==> Business/EDI/data/edifact/untdid/IDMD.d07a.csv # Messages (interactive) MsgCode:x:rel:org:z:SegmentGroup;label;SegCode;mandatory;class;repeats;;[mandatory;class;repeats;...] IHCEBI:D:07A:UN::;Interactive health insurance eligibility and benefits inquiry and;UIH;M;1;MSD;M;1;SG1;C;9;SG2;C;1;UIT;M;1 IHCEBI:D:07A:UN::SG1;SG01;PRT;M;1;NAA;C;9;CON;C;9;FRM;C;9 IHCEBI:D:07A:UN::SG2;SG02;DTI;M;1;ICI;C;1;FRM;C;9;SG3;C;999 IHCEBI:D:07A:UN::SG3;SG03;BCD;M;1;HDS;C;9;DTI;C;1;PRT;C;9;FRM;C;9 IHCLME:D:07A:UN::;Health care claim or encounter request and response - interactive;UIH;M;1;MSD;C;1;PRT;C;9;NAA;C;9;CON;C;9;BLI;C;1;ITC;C;1;FRM;C;99;SG1;C;3;SG2;C;99;UIT;M;1 IHCLME:D:07A:UN::SG1;SG01;OTI;M;1;NAA;C;2 IHCLME:D:07A:UN::SG2;SG02;PSI;M;1;DNT;C;35 ==> Business/EDI/data/edifact/untdid/IDSD.d07a.csv # Segments (interactive) SegCode;label;pos;code;mandatory;repeats(?) AAI;ACCOMMODATION ALLOCATION INFORMATION;010;E997;M;20; ADS;ADDRESS;010;E817;C;1;020;E001;C;1;030;3164;C;1;040;3251;C;1;050;3207;C;1;060;E819;C;1;070;E517;C;1; AAI => {label => 'ACCOMMODATION ALLOCATION INFORMATION', pos => '010', E997;M;20; TO DO
Parsing for interactive specs. SEE ALSO
edi4r - http://edi4r.rubyforge.org Business::EDI AUTHOR
Joe Atzberger perl v5.12.4 2010-09-08 Business::EDI::Spec(3pm)
All times are GMT -4. The time now is 07:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy