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-GTK(1)							 LIBREPORT MANUAL						     REPORT-GTK(1)

NAME
report-gtk - GUI tool to analyze and report ABRT problems SYNOPSIS
report-gtk [-vpdx] [-e EVENT] [-g GUI_FILE] PROBLEM_DIR DESCRIPTION
report-gtk is a graphical tool that reports application crashes and other problems caught by abrtd daemon, or created by other programs using libreport. report-gtk works with a single problem saved in specified PROBLEM_DIR. In the expert mode it enables access to and manipulation of problem data. OPTIONS
-d, --delete Remove PROBLEM_DIR after reporting -e EVENT Run only theset EVENTs on PROBLEM_DIR -g FILE Alternate GUI file -p Add program names to log -v, --verbose Be verbose -V, --version Display version and exit -x, --expert Enabled advanced features CONFIGURATION
Reporting work flow configuration These configuration files are placed in /usr/share/libreport/workflows. Each file has XML formatting with the following DTD: <!ELEMENT workflow (name+,description+,events*)> <!ELEMENT name (#PCDATA)> <!ATTLIST name xml:lang CDATA #IMPLIED> <!ELEMENT description (#PCDATA)> <!ATTLIST description xml:lang CDATA #IMPLIED> <!ELEMENT events = (event)+> <!ELEMENT event = (#PCDATA)> name User visible name description User visible description events List of executed events event Name of event. If event is not applicable on the problem data or if it is not defined then process continues with next event sibling. EXAMPLES
Simple reporting work flow <workflow> <name xml:lang="en">Example</name> <name xml:lang="cs">Piklad</name> <description xml:lang="en">Example description</description> <description xml:lang="cs">Piklad popisu</description> <evetns> <event>analyze_example</event> <event>collect_example</event> <event>report_example</event> </events> </workflow> AUTHORS
o ABRT team LIBREPORT 2.1.11 06/18/2014 REPORT-GTK(1)