advanced file renaming problem


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users advanced file renaming problem
# 1  
Old 08-01-2008
advanced file renaming problem

I know this is probably a question for the newbie forum, where it is also posted, but I thought maybe some of you pros might like to help me out anyway. Here is my problem:

I have to rename a batch of files that look like:
2001_0001.asc
2001_0002.asc
.
2001_0548.asc
2002_0184.asc
.
.
2006_0548.asc

The names are a date code, but they need to be altered such that 2001_0001.asc becomes 2000_183.asc, 2001_0184 becomes 2001_001, and 2006_0548.asc becomes 2006_365.asc.

so, I think it should start like:

for i in `ls*`
do

then things get a bit hazy
I will now convert to semi-programing speak

split aaaa_bbbb.asc into aaaa and bbbb
interpret strings aaaa and bbbb as numbers x and y respectively
if y - 183 < 1,
then x' = x - 1 and y' = y - 183 + 365,
else x' = x and y' = y - 183.
convert numbers x and y to strings aaaa' and bbb' (note the three digits
in bbb such that y' = 1 will convert to bbb' = 001)
rename file i to aaaa'_bbb'.asc

any help would be appreciated
thanks,
Image -TT Image
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem renaming files on Solaris 10 server

Good day all. I'm trying to rename some files in my home directory with some bizarre results. Basically I need to change the IP address in the filename to the hostname which I ggrep from within the file: -rw-r--r-- 1 bh694n nrc 5095 May 2 20:03 alarms_999.189.161.146.log... (2 Replies)
Discussion started by: BRH
2 Replies

2. UNIX for Dummies Questions & Answers

[Solved] File Splitting And Renaming Problem

OK So I Recently Bought A whatbox Seed-box Act!!:cool: I am connected to whatbox via SSH!!! Now i have downloaded a movie and renamed it to 2yify.mp4 (800MB):o When I TYPE the command to split it which is:) split -b 400m 2yify.mp4 It gets renamed into two parts with different names... (4 Replies)
Discussion started by: anime12345
4 Replies

3. UNIX for Advanced & Expert Users

Problem with renaming files

I have about 1000 files containing the character * in the name. I need to find these files and replace the * with a -. I am working with HP UX v11. I am using the following command find . -type f -name '*\**' -exec bash -c 'f="$1"; mv "$f" "${f//\*/-}"' - '{}' \ People tell me it works for... (4 Replies)
Discussion started by: MikeDavid
4 Replies

4. Shell Programming and Scripting

Problem renaming files using variables

Hi, I have the following problem: I have a list of files: 1.txt 2.txt 3.txt 4.txt Then I have a list of variable names inside variable.txt: A B C D I'd like to rename 1.txt, 2.txt etc using the variables from variable.txt (2 Replies)
Discussion started by: hubleo
2 Replies

5. Shell Programming and Scripting

Loop renaming files w/ a count problem

:wall: Hello there, basically in my program where im stuck at is when it comes to rename the files in a loop. - the program counts the number of files w a given name (works!) - and then if the number of files is greater or equal to the MAX_VERSIONS (numbers of files allowed w the... (1 Reply)
Discussion started by: thurft
1 Replies

6. Shell Programming and Scripting

File renaming problem

Can someone tell me how can i remove the RPCFTP word from RPCFTPfilelist.csv file ? (4 Replies)
Discussion started by: JSKOBS
4 Replies

7. Shell Programming and Scripting

Problem with renaming and saving

Hello mates, I am quite new to script programming and I am facing an uphill task to rename files in one folder. I have gone through similar posts but most of them deal with renaming files by changing the file extensions. Problem : I have a folder which contains files like... (5 Replies)
Discussion started by: chirag.joshi
5 Replies

8. UNIX for Advanced & Expert Users

problem with renaming files

Hi, I need to rename all the .txt files present in current directory to .dat files respectively in UNIX. for example: $ ls aaa.txt bbb.txt ccc.txt I need to change them to $ ls aaa.dat bbb.dat ccc.dat Is there any UNIX command to do this in one go? ... (3 Replies)
Discussion started by: Johny001
3 Replies

9. Shell Programming and Scripting

Problem renaming a file with single quotes

Hi, I am trying to create a script which validates the incoming source files. The script has File name Pattern as Argument. The First part of the script validates if there are any files available if then echo "\n Files are available to process \n" else echo "\n File does not... (9 Replies)
Discussion started by: dsshishya
9 Replies
Login or Register to Ask a Question
REPORT_EVENT.CONF(5)						 LIBREPORT MANUAL					      REPORT_EVENT.CONF(5)

NAME
report_event.conf - configuration file for libreport. DESCRIPTION
This configuration file specifies which programs should be run when the specified event occurs in problem directory lifetime. It consists of directives and rules. Directives start with a reserved word. Currently, there is only one directive, "include". include FILE This directive causes files which match FILE to be read and parsed as if they are inserted textually where this directive occurs. FILE can use shell pattern metacharacters (*,?,etc) to specify multiple files. Relative paths are interpreted relative to current file. Rule starts with a line with non-space leading character. All subsequent lines which start with space or tab form one rule. Note that separating newline is retained. Rules may be commented out with #. One # is sufficient to comment out even a multi-line rule (no need to comment out every line). Rules specify which programs to run on the problem directory. Each rule may have conditions to be checked before the program is run. Conditions have form VAR=VAL or VAL~=REGEX, where VAR is either word "EVENT" or a name of problem directory element to be checked (for example, "executable", "package", hostname" etc). If all conditions match, the remaining part of the rule (the "program" part) is run in the shell. All shell language constructs are valid. All stdout and stderr output is captured and passed to ABRT and possibly to ABRT's frontends and shown to the user. If the program terminates with nonzero exit code, the event processing is considered unsuccessful and is stopped. Last captured output line, if any, is considered to be the error message indicating the reason of the failure, and may be used by abrt as such. If the program terminates successfully, next rule is read and processed. This process is repeated until the end of this file. Event XML configuration These configuration files provides event meta data. Each file has XML formatting with the following DTD: <!ELEMENT event (name+,description+,requires-items?,exclude-items-by-default?,exclude-items-always?,exclude-binary-items?,include-items-by-default?,minimal-rating?,gui-review-elements?,options?)> <!ELEMENT name (#PCDATA)> <!ATTLIST name xml:lang CDATA #IMPLIED> <!ELEMENT description (#PCDATA)> <!ATTLIST description xml:lang CDATA #IMPLIED> <!ELEMENT requires-items (#PCDATA)> <!ELEMENT exclude-items-by-default (#PCDATA)> <!ELEMENT include-items-by-default (#PCDATA)> <!ELEMENT exclude-items-always (#PCDATA)> <!ELEMENT exclude-binary-items ("yes"|"no")> <!ELEMENT minimal-rating ("0"|"1"|"2"|"3"|"4")> <!ELEMENT gui-review-elements ("yes"|"no")> <!ELEMENT options (option*,advanced-options)> <!ELEMENT advanced-options (option)*> <!ELEMENT option (label+,description+,note-html+,allow-empty?,default-value?)> <!ATTLIST option type (text|bool|password|number|hint-html) #REQUIRED name CDATA #REQUIRED> <!ELEMENT label (#PCDATA)> <!ATTLIST label xml:lang CDATA #IMPLIED> <!ELEMENT note-html (#PCDATA)> <!ATTLIST note-html xml:lang CDATA #IMPLIED> <!ELEMENT allow-empty ("yes"|"no")> <!ELEMENT default-value (#PCDATA)> name User visible name of event description User visible description exclude-items-by-default Comma separated names of excluded problem elements. User can include any of these elements if he wishes it. include-items-by-default Comma separated names of included problem elements. User can exclude any of these elements if he wishes it. exclude-items-always Comma separated names of included problem elements. User cannot include any of these elements. exclude-binary-items If "yes" then all binary problem elements are excluded. User can include them if he wishes it. minimal-rating Minimal backtrace rating required for executing the event. Backtrace rating is a measure of backtrace usability and understandability. With an increasing number of unresolved frames the backtrace rating gets lower values. gui-review-elements If "yes", user must explicitly approve that all included problem elements can be published. If "no", the event is executed automatically. If not provided, "yes" is expected. advanced-options List of options which are hidden in the default view. label Event option label note-html Event option HTML formatted description allow-empty Determines if user can leave the option empty default-value A value which is used by default option:name Name of exported environment variable name. libreport tools communicate through Environment Variables. EXAMPLES
EVENT=post-create analyzer=Python abrt-action-analyze-python EVENT=post-create getent passwd "`cat uid`" | cut -d: -f1 >username SEE ALSO
abrtd(8) AUTHOR
Manual page written by Denys Vlasenko <dvlasenk@redhat.com[1]>. NOTES
1. dvlasenk@redhat.com mailto:dvlasenk@redhat.com LIBREPORT 2.1.11 06/18/2014 REPORT_EVENT.CONF(5)