Sponsored Content
Full Discussion: Renaming Files With 2 .
Top Forums UNIX for Dummies Questions & Answers Renaming Files With 2 . Post 302644699 by neutronscott on Tuesday 22nd of May 2012 09:42:03 AM
Old 05-22-2012
no sane person would script csh Smilie
i am not experienced with commercial versions. this should work with older ksh.
use "ksh script" or just chmod a+x script; ./script
Code:
#!/usr/bin/ksh

for br in *.rpt; do
        id1=${br##*_COB_}
        id2=${id1%.rpt}
        id2=${id2##*_}
        id1=${id1%%_*}
        bd=( cob*${id1}*.0${id2}.* )
        [[ -f "$bd" ]] || continue
        echo mv "$br" "$bd.br"
        echo mv "$bd" "$bd.bd"
done


Last edited by neutronscott; 05-22-2012 at 11:07 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

renaming files

i have a set of *.lst files. now i want to change the names from "lst" to "dat". how to do it? ex.: -rw-r--r-- 1 rram group 22 Sep 21 13:10 a.lst -rw-r--r-- 1 rram group 22 Sep 21 13:09 b.lst -rw-r--r-- 1 rram group 22 Sep 21 13:10 c.lst... (4 Replies)
Discussion started by: raguramtgr
4 Replies

2. UNIX for Dummies Questions & Answers

renaming the files

Hi All, Today I got a small problem while handling zipped files in PROD support. There are files in this format and I had to grep them reading some contents A.B.gz.C.D where A,B,C and D stand for variables (like FIRST.NAME.gz.MIDDLE.LAST). I know that these files are zipped files and If I... (1 Reply)
Discussion started by: adurga
1 Replies

3. UNIX for Dummies Questions & Answers

renaming files

directory name = /usr/tom/1997 files - ABC_1997_ST1_BCD.SQL BCD_1997_ST1_EFG_SAB.SQL TTT_EBC_1997_ST1_A.SQL sub directory - /usr/tom/1997/jan a) I want to just rename the all files ending with '.SQL' and also its contents in the 1997 directory(excluding subdirectories eg... (3 Replies)
Discussion started by: systemsb
3 Replies

4. UNIX for Dummies Questions & Answers

Renaming files

Hello! I am not familiar with UNIX and I have this problem: I need to move files from a UNIX machine to a PC. UNIX file names contain ":" as special character which is not recognized in a PC. How can I change ":" for "_" in the name of a bunch of files in UNIX? Thanks for your help. (7 Replies)
Discussion started by: Tygoon
7 Replies

5. UNIX for Dummies Questions & Answers

renaming files

I have a list of files named ab_*.csv I would like to remane them all by removing the ab_ and have *.csv I did the following but I am surely missing something. /* wrong script */ for i in `ls -1 ab_*`; do mv ab_$i $i; done Thanks in advance. (1 Reply)
Discussion started by: jxh461
1 Replies

6. Shell Programming and Scripting

renaming files

Hi all, using a utility image file was named starting with blank space and a blank space in between. I want to rename the files. file names are in the format " sb 12.tif"," sb 13.tif"," sb 14.tif" the files are in thousands. i want to rename as 12.tif, 13.tif, 14.tif.... thanks. (3 Replies)
Discussion started by: ahkverma
3 Replies

7. Shell Programming and Scripting

renaming files or adding a name in the beginning of all files in a folder

Hi All I have a folder that contains hundreds of file with a names 3.msa 4.msa 21.msa 6.msa 345.msa 456.msa 98.msa ... ... ... I need rename each of this file by adding "core_" in the begiining of each file such as core_3.msa core_4.msa core_21.msa (4 Replies)
Discussion started by: Lucky Ali
4 Replies

8. Shell Programming and Scripting

renaming files

Hi, I have a list of files in a folder with the same name ending (over 1000 files) joe.jpy.jpeg joe1.jpy.jpeg joe2.jpy.jpeg jon3.jpy.jpeg jor5.jpy.jpeg .....jpy.jpeg etc. I want to change jpy to hhk So the output will be: joe.hhk.jpeg joe1.hhk.jpeg joe2.hhk.jpeg jon3.hhk.jpeg... (3 Replies)
Discussion started by: kylle345
3 Replies

9. Shell Programming and Scripting

Renaming files

Hello, I am looking for a command line that will rename name files : f700_abc_o_t_MASTERID_AS_AE_20130323.csv like this f700_abc_o_t_MASTERID_AS_AE_20130324.csv The great idea could be to get the date stamp 20130323 and change any part of it, instead of just change the... (4 Replies)
Discussion started by: Aswex
4 Replies

10. Shell Programming and Scripting

Renaming multiple files in sftp server in a get files script

Hi, In sftp script to get files, I have to rename all the files which I am picking. Rename command does not work here. Is there any way to do this? I am using #!/bin/ksh For eg: sftp user@host <<EOF cd /path get *.txt rename *.txt *.txt.done ... (7 Replies)
Discussion started by: jhilmil
7 Replies
MPEGDEMUX(1)							     mpegdemux							      MPEGDEMUX(1)

NAME
mpegdemux - MPEG1/2 system stream demultiplexer SYNOPSIS
mpegdemux [options] [input [output]] DESCRIPTION
mpegdemux(1) is an MPEG1/MPEG2 system stream demultiplexer. It can be used to list the contents of an MPEG system stream and to extract elementary streams. mpegdemux(1) has four primary modes of operation: scan In this mode the MPEG system stream is scanned for elementary streams. list In this mode the contents of an MPEG system stream are listed in a textual form. This is useful to get an overview of what's in an MPEG file demux In this mode elementary streams are extracted from an MPEG system stream. The system stream packet structure is dissolved in the process. Typically each extracted stream is written to its own file. remux This is like demux, except that the MPEG system stream structure is left intact. This means that the output is again an MPEG system stream with all but the selected elementary streams removed. OPTIONS
-a, --ac3 AC3 sound packets in DVD MPEG2 streams have a 3 byte header that is neither part of the MPEG specification nor of the AC3 specifica- tion. When this option is used, these 3 bytes are removed to produce a correct AC3 stream. Note that this option applies to all selected substreams without checking whether they actually contain an AC3 elementary stream. -b, --base-name name When demultiplexing more than one stream, the output file names can be set using this option. To generate the output file name for a stream, every # character in name is replaced by a hex digit of the stream id. For example, to extract all video streams in one go, use something like $ mpegdemux -d -b video_##.m1v -s 0xc0-0xcf src.mpg to get files video_c0.m1v, video_c1.m1v, ... -c --scan Scan a system stream for elementary streams. This is the default mode. All streams and substreams are automatically selected when using this option. -d, --demux Demultiplex an MPEG system stream. The demultiplexed streams are written to the output file unless the --base-name option is used. If the --base-name option is not used, only one stream can be demultiplexed (if more streams are specified, they will be randomly interleaved in the output file). -D, --no-drop Don't drop incomplete packets in demuxing and remuxing mode. -e, --no-end Don't print end codes in listing mode. Additionally, in remuxing mode, make sure that there is exactly one end code at the end of the stream. -E, --empty-packs When streams are removed during remuxing, packs can become empty. Including these empty packs in the output is pointless and there- fore is not done by default. Use this option to force inclusion of all packs. -F, --first-pts In scan mode, in addition to each stream's first packet, also list the packet with the lowest presentation time stamp. -h, --no-system-headers Don't print system headers in listing mode. Additionally, in remuxing mode, don't repeat system headers. -i, --invalid spec Select invalid streams. Packets of invalid streams are not recognized as packets and their contents are parsed as MPEG system stream data rather than being skipped. This is useful for broken/incomplete streams. The syntax for spec is the same as for -s. Addition- ally, if spec is "-" then all streams that have not yet been selected by -s are made invalid. -k, --no-packs Don't print packs in listing mode. -K, --remux-skipped Copy bytes that are skipped while looking for a start code. -l, --list List the system headers, packs and packets in an MPEG system stream. -m, --packet-max-size size Set the maximum packet size to size. Packets in the input stream that are larger are considered invalid. As with the -i option, the packet is not simply skipped but parsed as MPEG system stream data. -p, --substream spec This option selects private substreams. Whenever Private Stream 1 (0xbd) is selected using -s, the substreams within that private stream can be selected using -p. The syntax for spec is the same as for -s. -P, --substream-map id1 id2 Remap substream id1 to id2 when remuxing. -r, --remux Remultiplex an MPEG system stream. The output MPEG system stream is written to the output file. Many options control what is copied from the input to the output and what is discarded. -s, --streams spec This option selects streams. spec specifies the stream IDs in the following form: [+|-]<id>[-<id>]{/[+|-]<id>[-<id>]} where id is either a numeric stream ID or one of all or none. A "-" in front of an ID range means exclusion. For example the spec -s 0xc0-0xcf/-0xc2 selects all video streams (0xc0 - 0xcf) except stream 0xc2. -S, --stream-map id1 id2 Remap stream id1 to id2 when remuxing. -t, --no-packets Don't print packets in listing mode. -u, --spu This option is used to extract DVD subtitles. It is necessary because the subtitle streams on DVD don't contain all the timing information (the time stamps in the packet headers are required). If this option is used during demultiplexing, the output files for all substreams are written in the following format: "SPU " (4 bytes) PTS (8 bytes, MSB first) SPU packet PTS (8 bytes) SPU packet and so on -x, --split Split the remuxed stream at sequence boundaries. This option is only meaningful in remuxing mode. It can not be used together with the -e option. The individual sequences are written to files whose name was set with the -b option. --help Print usage information --version Print version information EXAMPLES
Scan a system stream for elementary streams: $ mpegdemux -c -v src.mpg List the contents of an MPEG system stream: $ mpegdemux -l -k -s all -p all src.mpg Extract the first video stream: $ mpegdemux -d -s 0xe0 src.mpg dst.m1v Extract all audio streams: $ mpegdemux -d -s 0xc0-0xdf -b audio_##.mpa src.mpg Remove the second video stream: $ mpegdemux -r -s all/-0xc1 -p all src.mpg dst.mpg Extract the first AC3 audio stream from a DVD MPEG2 system stream: $ mpegdemux -d -s 0xbd -p 0x80 --ac3 src.mpg dst.ac3 Exchange the first and the second audio stream: $ mpegdemux -r -s all -p all -S 0xc0 0xc1 -S 0xc1 0xc0 src.mpg dst.mpg SEE ALSO
mplex(1) AUTHOR
Hampa Hug <hampa@hampa.ch> HH
2009-02-13 MPEGDEMUX(1)
All times are GMT -4. The time now is 09:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy